Double X-axis(t,p1) and single Y-axis(p2) depending on t

1 Ansicht (letzte 30 Tage)
uzzi
uzzi am 28 Feb. 2023
Kommentiert: Walter Roberson am 6 Mär. 2023
Hello,
I am trying to find the behaviour of P2 according to the changes of P1 from the table.
b=readtable('b1.xlsx');
So I plot like this
figure
p1=b.P1;
p2=b.P2;
plot(p1,p2)
It didn't turn out well
figure
yyaxis left
y2 = p2;
y = p1;
x = duration(b.Time);
plot(x,y2)
yyaxis right
plot(x,y)
Here, the data is controlled by the time and it turned out okay but I want the P1 on the x-axis to get the relationship with P2. So I thought about plotting according to my sketch. I want the p1 and time both in the x axis.
I want to draw the line for p1 vs p2 according to the time. Can someone help me with this problem?

Antworten (1)

KSSV
KSSV am 28 Feb. 2023
T = readtable('https://in.mathworks.com/matlabcentral/answers/uploaded_files/1309930/b1.xlsx') ;
t = duration(T.Time);
p1 = T.P1 ;
p2 = T.P2 ;
plot(t,p1,'r',t,p2,'b')
plotregression(p1,p2)
  1 Kommentar
Walter Roberson
Walter Roberson am 6 Mär. 2023
T = readtable('https://in.mathworks.com/matlabcentral/answers/uploaded_files/1309930/b1.xlsx') ;
[h,m,s] = hms(duration(T.Time));
p1 = T.P1 ;
p2 = T.P2 ;
plot3(s,p1,p2)
xlabel('time (s)'); ylabel('p1'); zlabel('p3')

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange

Produkte


Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by