Does anyone know how can I plot this?

조회 수: 1 (최근 30일)
Pul
Pul 2021년 7월 29일
댓글: Pul 2021년 8월 6일
Hello everyone,
I should plot the second column of TTS table at the place of variable "NEW".
Moreover, I should plot DATI_ECM and DATI_MAR from 1998 and not from 1993 as I did in the plot
Could anyone help me kindly?
  댓글 수: 1
Scott MacKenzie
Scott MacKenzie 2021년 7월 29일
편집: Scott MacKenzie 2021년 8월 4일
It would probably help if you spent a bit more time crafting a meaningful, self-contained question -- one that does not require us to download and study multiple data files and a script. Yes, it's good to have code and data to work with, but your question itself should be more detailed and informative.

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

답변 (2개)

Ashutosh Singh Baghel
Ashutosh Singh Baghel 2021년 8월 4일
편집: Ashutosh Singh Baghel 2021년 8월 5일
Hi,
I understand you faced issues with 'plot' function. Please update and execute your code with following suggestions -
1.Variable name "Height(mm)" must be changed to remove brackets with proper variable names. (Eg- "Height_mm"). A guide for valid variable names inside MATLAB can be found here.
2. For plotting Data from 1998 to 2019, use 'xlim' beneath the 'plot' function along with the limits you need.
Eg -
x_start = datetime(1998,01,01);
x_end = datetime(2019,31,12);
xlim([x_start x_end]);
Relevant information for datetime function can be found here.
  댓글 수: 3
Rik
Rik 2021년 8월 5일
Which version of Matlab are you using?
Pul
Pul 2021년 8월 5일
MATLAB R2021a.

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


Ashutosh Singh Baghel
Ashutosh Singh Baghel 2021년 8월 6일
편집: Ashutosh Singh Baghel 2021년 8월 6일
Hi pul,
I understand you wish to 'plot' 'TTS' table second variable against the 'T.Year' variable. This is not possible as the vectors must be of the same length. A possible workaround solution is by repeating the vector elements defined in 'TTS' variable 2 with the number of days present/left in each year defined by 'T.Year'. Please find the attached updated code for reference.
Also find the section in attached code about the 'xlim' function.
  댓글 수: 3
Ashutosh Singh Baghel
Ashutosh Singh Baghel 2021년 8월 6일
Hi,
From my understanding, this is a variable definition error which generally occurs when MATLAB cannot find a particular variable or MATLAB program file in the current directory or on the search path.
For further reference, please refer to Undefined Function or Variable page of MATLAB Documentation.
Pul
Pul 2021년 8월 6일
Hello Ashutosh,
yes, I solved that problem, but I still have this error: Error using datetime (line 647). Could not recognize the date/time format of '0'. You can specify a format using the 'InputFormat' parameter. If the date/time text contains day, month, or time zone names in a language foreign to the 'en_US' locale, those might not be recognized. You can specify a different locale using the 'Locale' parameter."
I tried to do the same thing with another variable("giulia_yearly_DELTA2" ), so I was taking into account "giulia_yearly_DELTA2" instead of "TTS" and doing the same steps you did, without success.
Thank you very much.
%LOAD ANNUALLY
% TT_SS=table2timetable(T);
% giulia_yearly=retime(TT_SS,'yearly','mean');
% TTS=timetable2table(giulia_yearly);
load('giulia_yearly_DELTA2');
%%%%%%%%%%%%%%%%%%%%%%%%% Updated Code starts here %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
GIULIA_yearly = giuliayearlyDELTA2{:,2}; %defining a new variable TTS_2 containing second variable of TTS
GIULIA_yearly (isnan(GIULIA_yearly )) = 0; %Replacing NaN with zero
NEW_3 = []; %initialise a new empty array for second variable in TTS table
xstart = datetime(giuliayearlyDELTA2.Year(1)); %start date of data in T table
xend = datetime(giuliayearlyDELTA2.Year(end)); %end date of data in T table

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

카테고리

Help CenterFile Exchange에서 Line Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by