How to plot a curve between 2 data sets

1 visualizzazione (ultimi 30 giorni)
Opariuc Andrei
Opariuc Andrei il 25 Ott 2021
Commentato: Opariuc Andrei il 25 Ott 2021
%% input data
P1=[2.3;3.9;3.5;4.8;5.5;6.3;7.4];
P2=[4.8;5.7;6.5;7.8;9.2;10.5;11.8];
D=[78;65;57;52;46;32;27];
%%
Dp=P2-P1;
Q=0.24*D;
%% plot
subplot(3,1,1);plot(Dp,'r*');grid on;axis tight;
subplot(3,1,2);plot(Q,'b*');grid on;axis tight;
subplot(3,1,3);plot(Dp,'r*');hold on;plot(Q,'b*');hold off;grid on;axis tight;legend('Dp','Q');
How do i plot a curve between Dp and Q ? in the third subplot

Risposte (2)

KSSV
KSSV il 25 Ott 2021
P1=[2.3;3.9;3.5;4.8;5.5;6.3;7.4];
P2=[4.8;5.7;6.5;7.8;9.2;10.5;11.8];
D=[78;65;57;52;46;32;27];
%%
Dp=P2-P1;
Q=0.24*D;
%
x = [1:length(Dp) flip(1:length(Q))] ;
y = [Dp; flip(Q)] ;
plot(x,y)

Chunru
Chunru il 25 Ott 2021
Do you mean Dp vs Q?
%% input data
P1=[2.3;3.9;3.5;4.8;5.5;6.3;7.4];
P2=[4.8;5.7;6.5;7.8;9.2;10.5;11.8];
D=[78;65;57;52;46;32;27];
%%
Dp=P2-P1;
Q=0.24*D;
%% plot
subplot(3,1,1);plot(Dp,'r*');grid on;axis tight;
subplot(3,1,2);plot(Q,'b*');grid on;axis tight;
%subplot(3,1,3);plot(Dp,'r*');hold on;plot(Q,'b*');hold off;grid on;axis tight;legend('Dp','Q');
subplot(3,1,3);plot(Dp, Q, 'r*');grid on;axis tight;xlabel('Dp'); ylabel('Q')
  1 Commento
Opariuc Andrei
Opariuc Andrei il 25 Ott 2021
a random curve between Dp and Q but withuot the curve connecting with any of the data ,Dp and Q have to be displayed as points as in the third subplot in my original code.

Accedi per commentare.

Prodotti


Release

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by