How to plot a curve between 2 data sets

2 次查看(过去 30 天)
%% 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

回答(2 个)

KSSV
KSSV 2021-10-25
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 2021-10-25
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 个评论
Opariuc Andrei
Opariuc Andrei 2021-10-25
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.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Annotations 的更多信息

标签

产品


版本

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by