Time series plot from structure array
이전 댓글 표시
Hello everyone,
I have a stock prices data from Yahoo Finance that I collected and placed in a structure array in the following manner:
clc
load('SP500stocks.mat'); %load data from a previously saved workspace
fields ={'Open', 'High', 'Low', 'Close', 'Volume'}; %create a variable fields
stocks_adj_close = rmfield(stocks, fields); % removes the fields mentionned here above
struct2csv(stocks_adj_close, 'SP500 Adjusted Stocks Prices (2000-20019).csv');
The result is:
stocks_adj_close =
1×503 struct array with fields:
Date
AdjClose
Ticker
The field "ticker" stores the ticker names of each SP500 companies and the period is from Jan-2000 to Jul-2019.
I would like to plot the stock prices of several comapnies in the same graph for a chosen period of my choice, say for instance AAPL, AIG, etc
How can I do that?
댓글 수: 2
Guillaume
2019년 7월 19일
A mat file instead of a screenshot would allow us to experiment with the data...
What format is the date stored as in the cell array? datetime? datestr? datenum? something else?
Most of the Tickers have 4913 dates. Are they identical for all of them? For the tickers with less dates, is it a subset of the 4913 dates? If yes, to these it would be a lot simpler to convert the structure into a table or timetable with columns as tickers. Plotting is just one line of code.
Even if the answer is no, as long as there's significant overlap, I'd still consider using that table.
Anthony Mukanya
2019년 7월 19일
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Dates and Time에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

