Plot date on X axis
1 次查看(过去 30 天)
显示 更早的评论
I am so confused on all other answers. Just trying to make a plot with date in X.
I created close=TSLA(:,5) and date=TSLA(:,1), they worked, then I tried plot(date,close), error. after I check other same question, I tried dn=datenum(date,'mm-dd-yyyy') but It give me error, I am stacked here. I am new to matlab. also how can I plot if the month is not number but like sep, oct?
采纳的回答
Walter Roberson
2021-2-14
close = TSLA{:,5};
date = TSLA{:,1};
plot(date, close)
2 个评论
Walter Roberson
2021-2-15
Yes, {} and () indexing is different for MATLAB.
There are two different major kinds of arrays in MATLAB: arrays of uniform objects, and container arrays in which every container might have a different kind of content. Consider for example:
The inside is a uniform array of drinking glasses. The MATLAB way of referring to any one of those glasses is with () brackets -- glasses(1,1) to glasses(3,4) for any one glass.
But now think about the box; close it up. It might be one of a palette-load of boxes the same size. Maybe all the boxes on the palette happen to contain the same kind of glasses; maybe some of them contain plates. You can have an array of boxes, and treat the boxes as individual objects, and when you do that you would still use () indexing -- boxes(1,1,1) to boxes(3,4,2) perhaps for a 3 x 4 x 2 stack of boxes. The () treat the array as uniform. You can take a subset of the boxes, like the left-most "face" of the palette, a 3 x 1 x 2 array of boxes, and you would still use () indexing for that.
But now you need to be able to talk about what is inside one of those containers, and inside the containers are arrays of objects. {} indexing is used to talk about what is inside a container. boxes{1,4,2} perhaps to open the box in row 1, column 4, layer 2. boxes{1,4,2} would refer to the entire contents of the box as an array; you can then use () indexing to refer to the objects within in. So perhaps boxes{1,4,2}(2,3) to refer to the glass in row 2, column 3, inside the box in row 1, column 4, layer 2. And if you open the next box, boxes{2,4,2} for example, it might be the plates, and might be a different sized of array. Maybe a single stack, 1 x 1 x 8.
So, () indexing: don't open any containers, treat the containers themselves as individual objects. {} indexing: open containers, don't expect that what you find there will be the same thing as what you find in a different container in the same array of containers.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Time Series Objects 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!