How to create a Line Plot from gauge Data?

Hey! I am very new to Matlab so I apologise for the simple questions.
I am trying to create a simple line figure with Time on the x-axis and wave amplitude on the y-axis. My data is currently in a string variable and a table variable.
>>plot(RightHead2(:,1),RightHead2(:,2))
Unrecognized function or variable 'Plot'.
>> plot(RightHead(:,1),RightHead(:,2))
Error using plot
Not enough input arguments.
>> plot(RightHead2)
Error using plot
Invalid data argument.
Thank you!

답변 (1개)

Arif Hoq
Arif Hoq 2022년 2월 28일
편집: Arif Hoq 2022년 2월 28일

0 개 추천

try this:
time=table2array(RightHead2(2:end,1));
waveAmp=table2array(RightHead2(2:end,2));
plot(time,waveAmp)
or simply
waveAmp=table2array(RightHead2(2:end,2));
plot(waveAmp)

댓글 수: 7

Elise Buller
Elise Buller 2022년 2월 28일
Thanks Arif! I was able to get a plot (see attached) however how can I change the x-axis to displaye the data instead of row numbers?
*There are 5175 rows of data in the table.
Thank you!
Arif Hoq
Arif Hoq 2022년 2월 28일
please attach your data.
Elise Buller
Elise Buller 2022년 2월 28일
Thanks Arif!
As you have 5175 data, you can not adjust the whole cell array in x axis. you can try with this
A=readtable('RightHead_2.csv','ReadVariableNames',true);
time=table2array(A(:,1));
waveAmp=table2array(A(:,2));
% take a range of value
% time1=time(1000:1030);
% C=categorical(time1);
% waveAmp1=waveAmp(1000:1030);
% plot(C,waveAmp1)
C=categorical(time);
plot(C,waveAmp)
xtickangle(90)
but if you consider a range of values you can have your plot. see here
A=readtable('RightHead_2.csv','ReadVariableNames',true);
Warning: Column headers from the file were modified to make them valid MATLAB identifiers before creating variable names for the table. The original column headers are saved in the VariableDescriptions property.
Set 'VariableNamingRule' to 'preserve' to use the original column headers as table variable names.
time=table2array(A(:,1));
waveAmp=table2array(A(:,2));
% take a range of value
time1=time(1000:1030);
C=categorical(time1);
waveAmp1=waveAmp(1000:1030);
plot(C,waveAmp1)
xtickangle(90)
Elise Buller
Elise Buller 2022년 2월 28일
Thank you so much for your help Arif!
Arif Hoq
Arif Hoq 2022년 2월 28일
my pleasure.

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

카테고리

도움말 센터File Exchange에서 Annotations에 대해 자세히 알아보기

제품

릴리스

R2020b

질문:

2022년 2월 28일

댓글:

2022년 2월 28일

Community Treasure Hunt

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

Start Hunting!

Translated by