Conditional Plotting
1 view (last 30 days)
Show older comments
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
0 Comments
Accepted Answer
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)
See Also
Categories
Find more on 2-D and 3-D Plots 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!