090函数表达式; function f=exlin(x) if x<0 f=-1; elseif x<1 f=x; elseif x<2 f=2-x; else f=0; end
091:硬循环语句: n=5;
for i=1:n
for j=1:n if i==j a(i,j)=2; else a(i,j)=0; end end end
while 循环语句: n=1;
while prod(1:n)<99^99; n=n+1 end n
:092 switch开关语句 a=input('a=?') switch a
case 1
disp('It is raning') case 0
36
disp('It do not know') case -1
disp('It is not ranging') otherwise
disp('It is raning ?') end
093画曲面函数: x1=linspace(-3,3,30) y1=linspace(-3,13,34) [x,y]=meshgrid(x1,y1);
z=x.^4+3*x.^2-2*x+6-2*y.*x.^2+y.^2-2*y; surf(x,y,z)
37