tickers='tickers.txt'; %list of tickers of financial stocks
price=hist_stock_data('09032015','09032016',tickers); %download data from yahoo.finanace
prices=zeros(size(price(1, 1).AdjClose,1),size(price,2));for t=1:size(price,2); prices(:,t)= price(1, t).AdjClose;end%I create an array in which I have a list of tickers called nomes
for t=1:size(price,2);nomes{1,t}=price(1, t).Ticker;end%couple is a string array nx2 with all possible pairs obtained from the “nomes”
cl=num2cell(prices); %to obtain a cell
ff=[nomes;cl]; %to have a matrix in which the first row is the name of stocks, and over there the historical prices for each stocks
%Now I want to obtain a for loop in which for each pair extrapolate the historical price from the matrix “prices”, utilizing the function ismember.
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
but 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".
Best Answer