如何实现两个变量区间的分段函数呢。
Show older comments
x=-2:0.01:2;
x=x+(x==0)*eps;
y=-2:0.01:2;
%y=y+(y==0)*eps;
[X,Y]=meshgrid(x,y);
m=1;
for xx=x,yy=Y
if(xx<=2&xx>0&&yy<=2&yy>0)
B=Y./X;
elseif(xx>=-2&xx<0&&yy<=2&yy>0)
B=Y./X+pi/2;
elseif(xx>=-2&xx<0&&yy>=-2&yy<0)
B=Y./X+pi;
else
B=Y./X+3*pi/2;
end
Z=m.*atan(B);
figure(1);
meshc(x,y,Z);
比如上边程序,红色字应该怎么改呢,如果没法改应该怎么正确写呢,求大佬解答
Accepted Answer
More Answers (0)
Categories
Find more on Language Fundamentals in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!