1、n“For the purposes of an engineer or scientist,MATLAB has the most features and is the best developed program in its class.”-IEEE Spectrum,Software Review,February 1997n“I have been amazed at how MATLAB can boost ones productivity.Anything from simple analysis to complex modeling and simulation can
2、be done in a fraction of the time it would take to write your own code.”Gregory E.Chamitoff,Ph.D.NASA,Johnson Space CenternFile types of MATLABif if elseif elseif elseelse endendif height170 disp(tall)elseif height=0)&(x=10)disp(x is in range 0,10)else disp(x is out of range)endfor index=for index=e
3、ndendThe are executed repeatedly.At each iteration,the variable index is assigneda new value from.for k=1:12 kfac=prod(1:k);disp(num2str(k),num2str(kfac)endfunction y=fact(n)%FACT Display factorials of integers 1.nif nargin 1 error(No input argument assigned)elseif n eps error(Input must be an integ
4、er)endfor k=1:n kfac=prod(1:k);disp(num2str(k),num2str(kfac)y(k)=kfac;end;%logomovie make movie of 360 degree logo tour logo;no_frames=40;dtheta=360/no_frames;for frame=1:no_frames,camorbit(dtheta,0)M(frame)=getframe(gcf);end%now display captured moviemovie(gcf,M);are executed repeatedly as long as
5、the evaluates to truewhile while statements endendk=1;while prod(1:k)=Inf,k=k+1;enddisp(Largest factorial in Matlab:,num2str(k-1);Polar plot:t=0:.01:2*pi;polar(t,abs(sin(2*t).*cos(2*t);Line plot:x=0:0.05:5;,y=sin(x.2);,plot(x,y);Stem plot:x=0:0.1:4;,y=sin(x.2).*exp(-x);stem(x,y)Mesh plot:z=peaks(25);,mesh(z);Surface plot:z=peaks(25);,surf(z);,colormap(jet);Contour plot:z=peaks(25);,contour(z,16);Quiver plot: