How to plot a curve between 2 data sets

조회 수: 1 (최근 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 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