Conditional Plotting

2 次查看(过去 30 天)
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

采纳的回答

Jonathan Sullivan
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')

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Simulink Functions 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by