How to plot a curve between 2 data sets

2 ビュー (過去 30 日間)
Opariuc Andrei
Opariuc Andrei 2021 年 10 月 25 日
コメント済み: Opariuc Andrei 2021 年 10 月 25 日
%% 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 Center および File ExchangeAnnotations についてさらに検索

タグ

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by