Hello,
I'm trying to fill the area between these two curves:
I had tried to use fill and patch function to shade but I didnt make it...
Any idea on how to fix the problem?
Thank you in advance for your help!
To get my first pic, please follow my step...
  1. Open 'combinefyp.slx'.
  2. Go to matlab and type the following variable.
ve = 25;
la = 4.6;
lx = 26.1;
yl = 3.7;
le = 4.6;
g = 9.8;
miu = 0.5;
3. Back to simulink then click 'Run'.
4. Go to matlab and type the following command.
plot(out.va1,out.L1);
hold on;
plot(out.va2,out.L2);
hold on;

댓글 수: 2

Rik
Rik 2022년 4월 2일
Can you show what syntax you tried for the call to patch? And can you attach the out variable in a mat file?
LIM MING HUI
LIM MING HUI 2022년 4월 2일
patch([out.va1, fliplr(out.va1)],[out.L1,fliplr(out.L2)],'r')
X=[out.va1,fliplr(out.va1)];
Y=[out.L1,fliplr(out.L2)];
fill(X,Y,'b');
-out.va1 and out.va2 are the same variables which is 25 to 50.

댓글을 달려면 로그인하십시오.

 채택된 답변

Voss
Voss 2022년 4월 2일

0 개 추천

My best guess for what's happening (since I don't have your variables and I don't have Simulink) is that the variables are column vectors, so that fliplr and horizontal concatenation is not an appropriate mathod for using the variables for patch vertices.
First, I try to reproduce the problem:
% I don't have Simulink, so I make a struct
% 'out' similar to yours (my best guess):
out = struct( ...
'va1',(25:50).', ...
'va2',(25:50).', ...
'L1',linspace(-5,25,26).', ...
'L2',0.1*(25:50).'.^2-3*(25:50).'+16.6);
% plot the lines the same way you do:
plot(out.va1,out.L1);
hold on;
plot(out.va2,out.L2);
% create the patches like you do:
patch([out.va1, fliplr(out.va1)],[out.L1,fliplr(out.L2)],'r');
X=[out.va1,fliplr(out.va1)];
Y=[out.L1,fliplr(out.L2)];
fill(X,Y,'b');
Now, I try to fix the problem (if my guess is correct):
figure();
% plot the lines the same way:
plot(out.va1,out.L1);
hold on;
plot(out.va2,out.L2);
% create a patch using flipud and vertical concatentation:
patch([out.va1; flipud(out.va1)],[out.L1; flipud(out.L2)],'b');

댓글 수: 1

LIM MING HUI
LIM MING HUI 2022년 4월 3일
U really help me a lot!!!! Thank you very much!!!!

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Data Distribution Plots에 대해 자세히 알아보기

태그

질문:

2022년 4월 2일

답변:

2022년 4월 3일

Community Treasure Hunt

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

Start Hunting!

Translated by