Error with ismember in a loop for

1 回表示 (過去 30 日間)
fede
fede 2016 年 4 月 11 日
回答済み: Jan 2016 年 4 月 11 日
tickers='tickers.txt';
price=hist_stock_data('09032015','09032016',tickers);
prices=zeros(size(price(1, 1).AdjClose,1),size(price,2));
for t=1:size(price,2);
prices(:,t)= price(1, t).AdjClose;
end
for t=1:size(price,2);
nomes{1,t}=price(1, t).Ticker;
end
couple=[nomes(myrow)',nomes(mycol)'];
cl=num2cell(prices);
ff=[nomes;cl];
for ii=1:size(couple,1);
looking_up=couple(ii,:);
[tf, coldix]=ismember(looking_up,ff(ii,:));
prices=ff(:,coldix(tf));
prices=prices(2:end,:);
prices=cell2mat(prices);
x(ii)=prices(:,2);
y(ii)=prices(:,1);
end
give me the following error: "Input A of class cell and input B of class cell must be cell arrays of strings, unless one is a string".

回答 (1 件)

Jan
Jan 2016 年 4 月 11 日
As the error message tells you, ismember operates on cells only, if they are cell strings. In your care the data are not cell strings. You can find out, what they are instead:
dbstop if all error
Then runs the code again. When Matlab stops at the error, type this in the command window:
class(looking_up)
class(looking_up{1})
class(ff)
class(ff{1})
Due to the absence of comments, we cannot guess what you want to achieve.

カテゴリ

Help Center および File ExchangeDebugging and Analysis についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by