Clear Filters
Clear Filters

Conditional Plotting

2 views (last 30 days)
old_user_rat
old_user_rat on 9 Apr 2012
Hi all,
I would like to plot the following graph only for the range where y2=>y1, leaving Z for y1>y2 empty.
y1=0:0.01:1;
y2=0:0.01:1;
[Y1,Y2]=meshgrid(y1,y2);
Z=((Y1 - Y2).*(Y1.^2 + 4*Y1.*Y2 - 6*Y1 + 7*Y2.^2 - 18*Y2 + 12))/12;
surf(Y1,Y2,Z)
xlabel('Y1')
ylabel('Y2')
How can I do this? Many thanks for any help. David

Accepted Answer

Jonathan Sullivan
Jonathan Sullivan on 9 Apr 2012
y1=0:0.01:1;
y2=0:0.01:1;
[Y1,Y2]=meshgrid(y1,y2);
Z=((Y1 - Y2).*(Y1.^2 + 4*Y1.*Y2 - 6*Y1 + 7*Y2.^2 - 18*Y2 + 12))/12;
Z(Y1 > Y2) = NaN;
surf(Y1,Y2,Z)
xlabel('Y1')
ylabel('Y2')

More Answers (0)

Categories

Find more on Simulink Functions in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!