答案 0 :(得分:0)
如果您创建一个网格网格以覆盖所有X,Y尺寸,那么相应地评估您的B [20,30,50],您应该能够将您的情节作为示例
[X,Y] = meshgrid(1.5:0.01:3.5,0.05:0.01:.45);
[m,n]=size(X);
for i=1:m
for j=1:n
if X(i,j)<2.1
BB(i,j)=X(i,j)^2+Y(i,j); %B20
elseif X(i,j)<2.7
BB(i,j)=X(i,j)+Y(i,j)^2; %B30
else
BB(i,j)=X(i,j)-Y(i,j); %B50
end
end
end
figure
surface(X,Y,BB);
grid on
view(3)