How to transform struc/field data to single matrix with specific columns
이전 댓글 표시
Hi, I have downloaded some stock price data into matlab for certain tickers and receive the data in a struc/table based format instead of the excel style with all the columns for close price with the date. Is there a way to extract just the relevant close price filed data and form a matrix with close price columns for a few tickers
here is some sample code:
[temp, status] = urlread(strcat('http://ichart.finance.yahoo.com/table.csv?s='...
,tickers{i},'&a=',bm,'&b=',bd,'&c=',by,'&d=',em,'&e=',ed,'&f=',...
ey,'&g=',freq,'&ignore=.csv'));
if status
% organize data by using the comma delimiter
[date, op, high, low, cl, volume, adj_close] = ...
strread(temp(43:end),'%s%s%s%s%s%s%s','delimiter',',');
stocks(idx).Ticker = tickers{i}; % obtain ticker symbol
stocks(idx).Date = date; % save date data
stocks(idx).Open = str2double(op); % save opening price data
stocks(idx).High = str2double(high); % save high price data
stocks(idx).Low = str2double(low); % save low price data
stocks(idx).Close = str2double(cl); % save closing price data
stocks(idx).Volume = str2double(volume); % save volume data
stocks(idx).AdjClose = str2double(adj_close); % save adjustied close data
idx = idx + 1; % increment stock index
end
Thanks for looking into the issue, any help/advice greatly appreciated,
Mark
답변 (2개)
pietro
2014년 7월 5일
0 개 추천
댓글 수: 4
Zahid
2014년 7월 5일
pietro
2014년 7월 6일
May you prepare a simple numeric example to let me to understand what you really need?
Zahid
2014년 7월 6일
pietro
2014년 7월 8일
Please be more specific, provide a numerical example like with the input and the outpu. something like:
p=struct('f1',[],'f2',[],'f3',[]);
p(1).f1=1
p(1).f2='20/05/2012';
....
output=.....
Otherwise I can't really help you.
카테고리
도움말 센터 및 File Exchange에서 Call Python from MATLAB에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!