필터 지우기
필터 지우기

Plot date on X axis

조회 수: 1 (최근 30일)
wenchong chen
wenchong chen 2021년 2월 14일
댓글: Walter Roberson 2021년 2월 15일
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?
  댓글 수: 2
Rik
Rik 2021년 2월 14일
Did you do a basic Matlab tutorial? Onramp should teach you how to deal with tables.
wenchong chen
wenchong chen 2021년 2월 14일
no, I am very new here, just started to watch

댓글을 달려면 로그인하십시오.

채택된 답변

Walter Roberson
Walter Roberson 2021년 2월 14일
close = TSLA{:,5};
date = TSLA{:,1};
plot(date, close)
  댓글 수: 2
wenchong chen
wenchong chen 2021년 2월 14일
amazing, that working, but that is how I did, why my code didn't work but yours work? is that ( ) and {} different?
Walter Roberson
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 CenterFile Exchange에서 Graphics Object Programming에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by