필터 지우기
필터 지우기

Error with ismember in a loop for

조회 수: 2 (최근 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 CenterFile Exchange에서 Characters and Strings에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by