数学建模案例MATLAB实用程序百例

数学建模案例MATLAB实用程序百例
数学建模案例MATLAB实用程序百例

实例1:三角函数曲线(1)function shili01 h0=figure('toolbar','none',... 'position',[198 56 350 300],...

'name','实例01');

h1=axes('parent',h0,...

'visible','off');

x=-pi:0.05:pi; y=sin(x);

plot(x,y);

xlabel('自变量X');

ylabel('函数值Y');

title('SIN( )函数曲线'); grid on

实例2:三角函数曲线(2)function shili02 h0=figure('toolbar','none',... 'position',[200 150 450 350],...

'name','实例02');

x=-pi:0.05:pi;

y=sin(x)+cos(x);

plot(x,y,'-*r','linewidth',1); grid on

xlabel('自变量X'); ylabel('函数值Y');

title('三角函数');

实例3:图形的叠加function shili03

h0=figure('toolbar','none',...

'position',[200 150 450 350],...

'name','实例03');

x=-pi:0.05:pi; y1=sin(x); y2=cos(x); plot(x,y1,...

'-*r',...

x,y2,...

'--og');

grid on xlabel('自变量X');

ylabel('函数值Y');

title('三角函数');

实例4:双y轴图形的绘制function shili04 h0=figure('toolbar','none',... 'position',[200 150 450 250],...

'name','实例04'); x=0:900;a=1000;b=0.005;

y1=2*x; y2=cos(b*x);

[haxes,hline1,hline2]=plotyy(x,y1,x,y2,'semilogy','plot'); axes(haxes(1))

ylabel('semilog plot');

axes(haxes(2)) ylabel('linear plot');

实例5:单个轴窗口显示多个图形function shili05 h0=figure('toolbar','none',...

'position',[200 150 450 250],...

'name','实例05'); t=0:pi/10:2*pi; [x,y]=meshgrid(t); subplot(2,2,1)

plot(sin(t),cos(t)) axis equal subplot(2,2,2) z=sin(x)-cos(y); plot(t,z)

axis([0 2*pi -2 2]) subplot(2,2,3) h=sin(x)+cos(y); plot(t,h)

axis([0 2*pi -2 2]) subplot(2,2,4) g=(sin(x).^2)-(cos(y).^2); plot(t,g)

axis([0 2*pi -1 1])

实例6:图形标注function shili06

h0=figure('toolbar','none',...

'position',[200 150 450 400],...

'name','实例06'); t=0:pi/10:2*pi; h=plot(t,sin(t));

xlabel('t=0到2\pi','fontsize',16); ylabel('sin(t)','fontsize',16);

title('\it{从0to2\pi 的正弦曲线}','fontsize',16) x=get(h,'xdata');

y=get(h,'ydata'); imin=find(min(y)==y); imax=find(max(y)==y); text(x(imin),y(imin),...

['\leftarrow最小值=',num2str(y(imin))],... 'fontsize',16)

text(x(imax),y(imax),...

['\leftarrow最大值=',num2str(y(imax))],... 'fontsize',16)

实例7:条形图形function shili07

h0=figure('toolbar','none',...

'position',[200 150 450 350],...

'name','实例07');

tiao1=[562 548 224 545 41 445 745 512];

tiao2=[47 48 57 58 54 52 65 48]; t=0:7;

bar(t,tiao1) xlabel('X轴'); ylabel('TIAO1值');

h1=gca; h2=axes('position',get(h1,'position')); plot(t,tiao2,'linewidth',3) set(h2,'yaxislocation','right','color','none','xticklabel',[])

实例8:区域图形function shili08

h0=figure('toolbar','none',...

'position',[200 150 450 250],...

'name','实例08');x=91:95;

profits1=[88 75 84 93 77];

profits2=[51 64 54 56 68];

profits3=[42 54 34 25 24];

profits4=[26 38 18 15 4];

area(x,profits1,'facecolor',[0.5 0.9 0.6],... 'edgecolor','b',...

'linewidth',3) hold on

area(x,profits2,'facecolor',[0.9 0.85 0.7],... 'edgecolor','y',...

'linewidth',3) hold on

area(x,profits3,'facecolor',[0.3 0.6 0.7],... 'edgecolor','r',...

'linewidth',3) hold on

area(x,profits4,'facecolor',[0.6 0.5 0.9],... 'edgecolor','m',...

'linewidth',3) hold off

set(gca,'xtick',[91:95])

set(gca,'layer','top') gtext('\leftarrow第一季度销量') gtext('\leftarrow第二季度销量') gtext('\leftarrow第三季度销量') gtext('\leftarrow第四季度销量') xlabel('年','fontsize',16);

ylabel('销售量','fontsize',16);

实例9:饼图的绘制function shili09

h0=figure('toolbar','none',...

'position',[200 150 450 250],...

'name','实例09'); t=[54 21 35; 68 54 35;

45 25 12;

48 68 45;

68 54 69];

x=sum(t);

h=pie(x); textobjs=findobj(h,'type','text'); str1=get(textobjs,{'string'});

val1=get(textobjs,{'extent'}); oldext=cat(1,val1{:}); names={'商品一:';'商品二:';'商品三:'}; str2=strcat(names,str1);

set(textobjs,{'string'},str2) val2=get(textobjs,{'extent'}); newext=cat(1,val2{:}); offset=sign(oldext(:,1)).*(newext(:,3)-oldext(:,3))/2;

pos=get(textobjs,{'position'});

textpos=cat(1,pos{:}); textpos(:,1)=textpos(:,1)+offset; set(textobjs,{'position'},num2cell(textpos,[3,2]))

实例10:阶梯图function shili10

h0=figure('toolbar','none',...

'position',[200 150 450 400],...

'name','实例10'); a=0.01;

b=0.5; t=0:10;

f=exp(-a*t).*sin(b*t); stairs(t,f)

hold on plot(t,f,':*') hold off

glabel='函数e^{-(\alpha*t)}sin\beta*t的阶梯图'; gtext(glabel,'fontsize',16)

xlabel('t=0:10','fontsize',16)

axis([0 10 -1.2 1.2])

实例11:枝干图function shili11

h0=figure('toolbar','none',...

'position',[200 150 450 350],...

'name','实例11'); x=0:pi/20:2*pi; y1=sin(x);

y2=cos(x); h1=stem(x,y1+y2); hold on

h2=plot(x,y1,'^r',x,y2,'*g'); hold off

h3=[h1(1);h2];

legend(h3,'y1+y2','y1=sin(x)','y2=cos(x)') xlabel('自变量X'); ylabel('函数值Y'); title('正弦函数与余弦函数的线性组合'); 实例12:罗盘图function shili12

h0=figure('toolbar','none',...

'position',[200 150 450 250],...

'name','实例12'); winddirection=[54 24 65 84

256 12 235 62

125 324 34 254];

windpower=[2 5 5 3

6 8 12

7 6 14 10 8];

rdirection=winddirection*pi/180; [x,y]=pol2cart(rdirection,windpower); compass(x,y);

desc={'风向和风力', '北京气象台', '10月1日0:00到', '10月1日12:00'};

gtext(desc)

实例13:轮廓图function shili13

h0=figure('toolbar','none',...

'position',[200 150 450 250],...

'name','实例13'); [th,r]=meshgrid((0:10:360)*pi/180,0:0.05:1);

[x,y]=pol2cart(th,r);

z=x+i*y;

f=(z.^4-1).^(0.25);

contour(x,y,abs(f),20) axis equal

xlabel('实部','fontsize',16);

ylabel('虚部','fontsize',16);

h=polar([0 2*pi],[0 1]); delete(h)

hold on contour(x,y,abs(f),20)

实例14:交互式图形function shili14

h0=figure('toolbar','none',...

'position',[200 150 450 250],...

'name','实例14');

axis([0 10 0 10]);

hold on x=[];

y=[]; n=0;

disp('单击鼠标左键点取需要的点'); disp('单击鼠标右键点取最后一个点');

but=1;

while but==1

[xi,yi,but]=ginput(1);

plot(xi,yi,'bo') n=n+1;

disp('单击鼠标左键点取下一个点'); x(n,1)=xi;

y(n,1)=yi;

end t=1:n;

ts=1:0.1:n;

xs=spline(t,x,ts); ys=spline(t,y,ts); plot(xs,ys,'r-'); hold off

实例14:交互式图形

function shili14 h0=figure('toolbar','none',...

'position',[200 150 450 250],...

'name','实例14'); axis([0 10 0 10]);

hold on x=[];

y=[]; n=0;

disp('单击鼠标左键点取需要的点'); disp('单击鼠标右键点取最后一个点');

but=1;

while but==1

[xi,yi,but]=ginput(1);

plot(xi,yi,'bo') n=n+1;

disp('单击鼠标左键点取下一个点'); x(n,1)=xi;

y(n,1)=yi;

end t=1:n;

ts=1:0.1:n;

xs=spline(t,x,ts); ys=spline(t,y,ts); plot(xs,ys,'r-'); hold off

实例15:变换的傅立叶函数曲线function shili15

h0=figure('toolbar','none',...

'position',[200 150 450 250],...

'name','实例15'); axis equal m=moviein(20,gcf);

set(gca,'nextplot','replacechildren') h=uicontrol('style','slider','position',...

[100 10 500 20],'min',1,'max',20)

for j=1:20

plot(fft(eye(j+16))) set(h,'value',j)

m(:,j)=getframe(gcf);

end clf;

axes('position',[0 0 1 1]); movie(m,30)

实例16:劳伦兹非线形方程的无序活动function shili15

h0=figure('toolbar','none',...

'position',[200 150 450 250],...

'name','实例15'); axis equal m=moviein(20,gcf);

set(gca,'nextplot','replacechildren') h=uicontrol('style','slider','position',...

[100 10 500 20],'min',1,'max',20)

for j=1:20

plot(fft(eye(j+16)))

set(h,'value',j)

m(:,j)=getframe(gcf);end clf;

axes('position',[0 0 1 1]); movie(m,30)

实例17:填充图function shili17

h0=figure('toolbar','none',...

'position',[200 150 450 250],...

'name','实例17');

t=(1:2:15)*pi/8; x=sin(t);

y=cos(t); fill(x,y,'r') axis square off

text(0,0,'STOP',... 'color',[1 1 1],...

'fontsize',50,... 'horizontalalignment','center')

实例18:条形图和阶梯形图function shili18 h0=figure('toolbar','none',... 'position',[200 150 450 250],...

'name','实例18'); subplot(2,2,1)

x=-3:0.2:3;

y=exp(-x.*x); bar(x,y)

title('2-D Bar Chart') subplot(2,2,2)

x=-3:0.2:3;

y=exp(-x.*x);

bar3(x,y,'r')

title('3-D Bar Chart') subplot(2,2,3)

x=-3:0.2:3;

y=exp(-x.*x); stairs(x,y) title('Stair Chart') subplot(2,2,4)

x=-3:0.2:3;

y=exp(-x.*x); barh(x,y)

title('Horizontal Bar Chart')

实例19:三维曲线图function shili19

h0=figure('toolbar','none',...

'position',[200 150 450 400],...

'name','实例19'); subplot(2,1,1) x=linspace(0,2*pi); y1=sin(x);

y2=cos(x); y3=sin(x)+cos(x);

z1=zeros(size(x)); z2=0.5*z1;

z3=z1; plot3(x,y1,z1,x,y2,z2,x,y3,z3) grid on

xlabel('X轴');

ylabel('Y轴');

zlabel('Z轴'); title('Figure1:3-D Plot') subplot(2,1,2) x=linspace(0,2*pi);

y1=sin(x);

y2=cos(x); y3=sin(x)+cos(x); z1=zeros(size(x)); z2=0.5*z1;

z3=z1; plot3(x,z1,y1,x,z2,y2,x,z3,y3) grid on

xlabel('X轴');

ylabel('Y轴');

zlabel('Z轴'); title('Figure2:3-D Plot')

实例20:图形的隐藏属性function shili20 h0=figure('toolbar','none',...

'position',[200 150 450 300],...

'name','实例20'); subplot(1,2,1) [x,y,z]=sphere(10); mesh(x,y,z)

axis off title('Figure1:Opaque') hidden on subplot(1,2,2) [x,y,z]=sphere(10); mesh(x,y,z) axis off title('Figure2:Transparent') hidden off

实例21PEAKS函数曲线function shili21

h0=figure('toolbar','none',...

'position',[200 100 450 450],...

'name','实例21');

[x,y,z]=peaks(30); subplot(2,1,1) x=x(1,:);

y=y(:,1);

i=find(y>0.8&y<1.2); j=find(x>-0.6&x<0.5);

z(i,j)=nan*z(i,j); surfc(x,y,z)

xlabel('X轴');

ylabel('Y轴');

zlabel('Z轴'); title('Figure1:surfc函数形成的曲面')

subplot(2,1,2) x=x(1,:);

y=y(:,1);

i=find(y>0.8&y<1.2); j=find(x>-0.6&x<0.5); z(i,j)=nan*z(i,j); surfl(x,y,z) xlabel('X轴');

ylabel('Y轴');

zlabel('Z轴'); title('Figure2:surfl函数形成的曲面')

实例22:片状图function shili22

h0=figure('toolbar','none',...

'position',[200 150 550 350],...

'name','实例22'); subplot(1,2,1) x=rand(1,20);

y=rand(1,20); z=peaks(x,y*pi); t=delaunay(x,y)

trimesh(t,x,y,z) hidden off

title('Figure1:Triangular Surface Plot'); subplot(1,2,2)

x=rand(1,20);

y=rand(1,20); z=peaks(x,y*pi); t=delaunay(x,y); trisurf(t,x,y,z)

title('Figure1:Triangular Surface Plot');

实例23:视角的调整function shili23

h0=figure('toolbar','none',...

'position',[200 150 450 350],...

'name','实例23');

x=-5:0.5:5;

[x,y]=meshgrid(x); r=sqrt(x.^2+y.^2)+eps; z=sin(r)./r; subplot(2,2,1) surf(x,y,z) xlabel('X-axis')

ylabel('Y-axis')

zlabel('Z-axis') title('Figure1') view(-37.5,30)

subplot(2,2,2) surf(x,y,z) xlabel('X-axis')

ylabel('Y-axis')

zlabel('Z-axis') title('Figure2') view(-37.5+90,30)

subplot(2,2,3) surf(x,y,z)

xlabel('X-axis')

ylabel('Y-axis')

zlabel('Z-axis') title('Figure3') view(-37.5,60)

subplot(2,2,4) surf(x,y,z)

xlabel('X-axis')

ylabel('Y-axis')

zlabel('Z-axis') title('Figure4') view(180,0)

实例24:向量场的绘制function shili24

h0=figure('toolbar','none',...

'position',[200 150 450 350],...

'name','实例24'); subplot(2,2,1) z=peaks;

ribbon(z) title('Figure1')

subplot(2,2,2) [x,y,z]=peaks(15); [dx,dy]=gradient(z,0.5,0.5); contour(x,y,z,10) hold on quiver(x,y,dx,dy) hold off title('Figure2') subplot(2,2,3) [x,y,z]=peaks(15);

[nx,ny,nz]=surfnorm(x,y,z); surf(x,y,z)

hold on quiver3(x,y,z,nx,ny,nz) hold off title('Figure3') subplot(2,2,4) x=rand(3,5);

y=rand(3,5);

z=rand(3,5);

c=rand(3,5);

fill3(x,y,z,c) grid on title('Figure4')

实例25:灯光定位function shili25

h0=figure('toolbar','none',...

'position',[200 150 450 250],...

'name','实例25'); vert=[1 1 1;1 2 1;

2 2 1;2 1 1;

1 1 2;1

2 2;

2 2 2;2 1 2];

fac=[1 2 3 4;2 6 7 3;

4 3 7 8;1

5 8 4;

1 2 6 5;5 6 7 8];

grid off sphere(36)

h=findobj('type','surface'); set(h,'facelighting','phong',... 'facecolor',...

'interp',...

'edgecolor',[0.4 0.4 0.4],... 'backfacelighting',...

'lit') hold on

patch('faces',fac,'vertices',vert,... 'facecolor','y');

light('position',[1 3 2]);

light('position',[-3 -1 3]); material shiny

axis vis3d off hold off 实例26:柱状图function shili26

h0=figure('toolbar','none',...

'position',[200 50 450 450],...

'name','实例26'); subplot(2,1,1)

x=[5 2 18 7 3

9 8 6

5 5 5

4 3 2];

bar(x) xlabel('X轴');

ylabel('Y轴');

title('第一子图'); subplot(2,1,2) y=[5 2 1

8 7 3

9 8 6

5 5 5

4 3 2];

barh(y) xlabel('X轴');

ylabel('Y轴');

title('第二子图');

实例27:设置照明方式function shili27

h0=figure('toolbar','none',...

'position',[200 150 450 350],...

'name','实例27'); subplot(2,2,1)

sphere shading flat camlight left

camlight right lighting flat colorbar

axis off title('Figure1') subplot(2,2,2) sphere

shading flat camlight left camlight right lighting gouraud colorbar

axis off title('Figure2') subplot(2,2,3) sphere

shading interp camlight right camlight left lighting phong

colorbar axis off

title('Figure3') subplot(2,2,4) sphere

shading flat camlight left camlight right lighting none colorbar

axis off title('Figure4')

实例28:羽状图function shili28

h0=figure('toolbar','none',...

'position',[200 150 450 350],...

'name','实例28'); subplot(2,1,1) alpha=90:-10:0; r=ones(size(alpha)); m=alpha*pi/180; n=r*10; [u,v]=pol2cart(m,n); feather(u,v) title('羽状图') axis([0 20 0 10]) subplot(2,1,2) t=0:0.5:10;

x=0.05+i;

y=exp(-x*t); feather(y)

title('复数矩阵的羽状图')

实例29:立体透视(1)function shili29

h0=figure('toolbar','none',...

'position',[200 150 450 250],...

'name','实例29'); [x,y,z]=meshgrid(-2:0.1:2,...

-2:0.1:2,...

-2:0.1:2);

v=x.*exp(-x.^2-y.^2-z.^2); grid on

for i=-2:0.5:2;

h1=surf(linspace(-2,2,20),...

linspace(-2,2,20),... zeros(20)+i);

rotate(h1,[1 -1 1],30)

dx=get(h1,'xdata');

dy=get(h1,'ydata');

dz=get(h1,'zdata'); delete(h1)

slice(x,y,z,v,[-2 2],2,-2) hold on slice(x,y,z,v,dx,dy,dz) hold off axis tight

view(-5,10) drawnow

end

实例30:立体透视(2)function shili30

h0=figure('toolbar','none',...

'position',[200 150 450 250],...

'name','实例30'); [x,y,z]=meshgrid(-2:0.1:2,...

-2:0.1:2,...

-2:0.1:2);

v=x.*exp(-x.^2-y.^2-z.^2); [dx,dy,dz]=cylinder; slice(x,y,z,v,[-2 2],2,-2) for i=-2:0.2:2

h=surface(dx+i,dy,dz); rotate(h,[1 0 0],90)

xp=get(h,'xdata');

yp=get(h,'ydata');

zp=get(h,'zdata'); delete(h)

hold on hs=slice(x,y,z,v,xp,yp,zp); axis tight

xlim([-3 3])

view(-10,35) drawnow delete(hs)

hold offend

实例31:表面图形function shili31

h0=figure('toolbar','none',...

'position',[200 150 550 250],...

'name','实例31'); subplot(1,2,1) x=rand(100,1)*16-8; y=rand(100,1)*16-8; r=sqrt(x.^2+y.^2)+eps; z=sin(r)./r;

xlin=linspace(min(x),max(x),33); ylin=linspace(min(y),max(y),33); [X,Y]=meshgrid(xlin,ylin); Z=griddata(x,y,z,X,Y,'cubic'); mesh(X,Y,Z)

axis tight hold on

plot3(x,y,z,'.','Markersize',20) subplot(1,2,2)

k=5;

n=2^k-1;

theta=pi*(-n:2:n)/n; phi=(pi/2)*(-n:2:n)'/n; X=cos(phi)*cos(theta); Y=cos(phi)*sin(theta); Z=sin(phi)*ones(size(theta));

colormap([0 0 0;1 1 1]) C=hadamard(2^k); surf(X,Y,Z,C)

axis square

实例32:沿曲线移动的小球h0=figure('toolbar','none',...

'position',[198 56 408 468],...

'name','实例32');

h1=axes('parent',h0,... 'position',[0.15 0.45 0.7 0.5],...

'visible','on'); t=0:pi/24:4*pi; y=sin(t); plot(t,y,'b') n=length(t);

h=line('color',[0 0.5 0.5],...

'linestyle','.',... 'markersize',25,...

'erasemode','xor'); k1=uicontrol('parent',h0,...

'style','pushbutton',...

'position',[80 100 50 30],...

'string','开始',...

'callback',[...

'i=1;',...

'k=1;,',...

'm=0;,',...

'while 1,',...

'if k==0,',...

'break,',...

'end,',...

'if k~=0,',... 'set(h,''xdata'',t(i),''ydata'',y(i)),',... 'drawnow;,',... 'i=i+1;,',...

'if i>n,',...

'm=m+1;,',...

'i=1;,',...

'end,',...

'end,',...

'end']); k2=uicontrol('parent',h0,...

'style','pushbutton',...

'position',[180 100 50 30],...

'string','停止',...

'callback',[...

'k=0;,',...

'set(e1,''string'',m),',...

'p=get(h,''xdata'');,',...

'q=get(h,''ydata'');,',... 'set(e2,''string'',p);,',...

'set(e3,''string'',q)']); k3=uicontrol('parent',h0,...

'style','pushbutton',...

'position',[280 100 50 30],...

'string','关闭',...

'callback','close');

e1=uicontrol('parent',h0,... 'style','edit',...

'position',[60 30 60 20]); t1=uicontrol('parent',h0,...

'style','text',...

'string','循环次数',...

'position',[60 50 60 20]); e2=uicontrol('parent',h0,...

'style','edit',... 'position',[180 30 50 20]);

t2=uicontrol('parent',h0,... 'style','text',...

'string','终点的X坐标值',... 'position',[155 50 100 20]);

e3=uicontrol('parent',h0,... 'style','edit',... 'position',[300 30 50 20]); t3=uicontrol('parent',h0,... 'style','text',...

'string','终点的Y坐标值',... 'position',[275 50 100 20]);

实例33:曲线转换按钮h0=figure('toolbar','none',...

'position',[200 150 450 250],...

'name','实例33'); x=0:0.5:2*pi;

y=sin(x);

h=plot(x,y);

grid on huidiao=[...

'if i==1,',...

'i=0;,',...

'y=cos(x);,',...

'delete(h),',... 'set(hm,''string'',''正弦函数''),',... 'h=plot(x,y);,',...

'grid on,',...

'else if i==0,',...

'i=1;,',...

'y=sin(x);,',... 'set(hm,''string'',''余弦函数''),',... 'delete(h),',...

'h=plot(x,y);,',... 'grid on,',...

'end,',... 'end'];

hm=uicontrol(gcf,'style','pushbutton',... 'string','余弦函数',... 'callback',huidiao);

i=1;

set(hm,'position',[250 20 60 20]);

set(gca,'position',[0.2 0.2 0.6 0.6]) title('按钮的使用')

hold on

实例34:栅格控制按钮h0=figure('toolbar','none',... 'position',[200 150 450 250],...

'name','实例34'); x=0:0.5:2*pi;

y=sin(x);

plot(x,y)

huidiao1=[...

'set(h_toggle2,''value'',0),',... 'grid on,',...

];

huidiao2=[...

'set(h_toggle1,''value'',0),',... 'grid off,',...

];

h_toggle1=uicontrol(gcf,'style','togglebutton',... 'string','grid on',... 'value',0,...

'position',[20 45 50 20],... 'callback',huidiao1);

h_toggle2=uicontrol(gcf,'style','togglebutton',... 'string','grid off',... 'value',0,...

'position',[20 20 50 20],... 'callback',huidiao2);

set(gca,'position',[0.2 0.2 0.6 0.6]) title('开关按钮的使用')

实例35:编辑框的使用h0=figure('toolbar','none',...

'position',[200 150 350 250],...

'name','实例35'); f='Please input the letter'; huidiao1=[...

'g=upper(f);,',... 'set(h2_edit,''string'',g),',...

];

huidiao2=[...

'g=lower(f);,',... 'set(h2_edit,''string'',g),',...

];

h1_edit=uicontrol(gcf,'style','edit',... 'position',[100 200 100 50],...

'HorizontalAlignment','left',... 'string','Please input the letter',... 'callback','f=get(h1_edit,''string'');',... 'background','w',...

'max',5,...

'min',1); h2_edit=uicontrol(gcf,'style','edit',...

'HorizontalAlignment','left',... 'position',[100 100 100 50],...

'background','w',...

'max',5,...

'min',1); h1_button=uicontrol(gcf,'style','pushbutton',...

'string','小写变大写',...

'position',[100 45 100 20],...

'callback',huidiao1); h2_button=uicontrol(gcf,'style','pushbutton',...

'string','大写变小写',...

'position',[100 20 100 20],...

'callback',huidiao2);

实例36:弹出式菜单h0=figure('toolbar','none',...

'position',[200 150 450 250],...

'name','实例36'); x=0:0.5:2*pi; y=sin(x);

h=plot(x,y); grid on

hm=uicontrol(gcf,'style','popupmenu',... 'string',...

'sin(x)|cos(x)|sin(x)+cos(x)|exp(-sin(x))',... 'position',[250 20 50 20]);

set(hm,'value',1) huidiao=[...

'v=get(hm,''value'');,',... 'switch v,',...

'case 1,',...

'delete(h),',...

'y=sin(x);,',...

'h=plot(x,y);,',... 'grid on,',...

'case 2,',...

'delete(h),',...

'y=cos(x);,',...

'h=plot(x,y);,',...

'grid on,',...

'case 3,',...

'delete(h),',...

'y=sin(x)+cos(x);,',...

'h=plot(x,y);,',... 'grid on,',...

'case 4,',...

'delete(h),',... 'y=exp(-sin(x));,',...

'h=plot(x,y);,',... 'grid on,',... 'end'];

set(hm,'callback',huidiao) set(gca,'position',[0.2 0.2 0.6 0.6]) title('弹出式菜单的使用')

hold on

实例37:滑标的使用h0=figure('toolbar','none',...

'position',[200 150 450 250],...

'name','实例37'); [x,y]=meshgrid(-8:0.5:8); r=sqrt(x.^2+y.^2)+eps; z=sin(r)./r;

h0=mesh(x,y,z);

h1=axes('position',... [0.2 0.2 0.5 0.5],...

'visible','off'); htext=uicontrol(gcf,...

'units','points',...

'position',[20 30 45 15],...

'string','brightness',...

'style','text'); hslider=uicontrol(gcf,...

'units','points',...

'position',[10 10 300 15],...

'min',-1,...

'max',1,...

'style','slider',... 'callback',...

'brighten(get(hslider,''value''))');

实例38:多选菜单h0=figure('toolbar','none',...

'position',[200 150 450 250],...

'name','实例38'); [x,y]=meshgrid(-8:0.5:8); r=sqrt(x.^2+y.^2)+eps; z=sin(r)./r;

h0=mesh(x,y,z); hlist=uicontrol(gcf,'style','listbox',...

'string','default|spring|summer|autumn|winter',... 'max',5,...

'min',1,...

'position',[20 20 80 100],...

'callback',[... 'k=get(hlist,''value'');,',... 'switch k,',...

'case 1,',...

'colormap default,',...

'case 2,',...

'colormap spring,',...

'case 3,',...

'colormap summer,',...

'case 4,',...

'colormap autumn,',...

'case 5,',...

'colormap winter,',...

'end']);

实例39:菜单控制的使用h0=figure('toolbar','none',...

'position',[200 150 450 250],...

'name','实例39'); x=0:0.5:2*pi;

y=cos(x);

h=plot(x,y); grid on

set(gcf,'toolbar','none') hm=uimenu('label','example'); huidiao1=[...

'set(hm_gridon,''checked'',''on''),',...

'set(hm_gridoff,''checked'',''off''),',... 'grid on'];

huidiao2=[...

'set(hm_gridoff,''checked'',''on''),',...

'set(hm_gridon,''checked'',''off''),',... 'grid off'];

hm_gridon=uimenu(hm,'label','grid on',... 'checked','on',... 'callback',huidiao1); hm_gridoff=uimenu(hm,'label','grid off',... 'checked','off',... 'callback',huidiao2);

实例40:UIMENU菜单的应用h0=figure('toolbar','none',...

'position',[200 150 450 250],...

'name','实例40');

h1=uimenu(gcf,'label','函数');

h11=uimenu(h1,'label','轮廓图',... 'callback',[...

'set(h31,''checked'',''on''),',...

'set(h32,''checked'',''off''),',...

'[x,y,z]=peaks;,',...

'contour3(x,y,z,30)']);

h12=uimenu(h1,'label','高斯分布',... 'callback',[...

'set(h31,''checked'',''on''),',...

'set(h32,''checked'',''off''),',... 'mesh(peaks);,',...

'axis tight']); h13=uimenu(h1,'label','Sinc函数',... 'callback',[... 'set(h31,''checked'',''on''),',...

'set(h32,''checked'',''off''),',...

'[x,y]=meshgrid(-8:0.5:8);,',...

'r=sqrt(x.^2+y.^2)+eps;,',...

'z=sin(r)./r;,',...

'mesh(x,y,z)']);

h2=uimenu(gcf,'label','色彩'); hl2(1)=uimenu(h2,'label','Default',...

'checked','on',... 'callback',... [...

'set(hl2,''checked'',''off''),',...

'set(hl2(1),''checked'',''on''),',... 'colormap(''default'')']);

hl2(2)=uimenu(h2,'label','spring',... 'callback',...

[...

'set(hl2,''checked'',''off''),',...

'set(hl2(2),''checked'',''on''),',...

'colormap(spring)']); hl2(3)=uimenu(h2,'label','Summer',...

'callback',... [...

'set(hl2,''checked'',''off''),',...

'set(hl2(3),''checked'',''on''),',... 'colormap(summer)']);

hl2(4)=uimenu(h2,'label','Autumn',... 'callback',...

[...

'set(hl2,''checked'',''off''),',...

'set(hl2(4),''checked'',''on''),',... 'colormap(autumn)']);

hl2(5)=uimenu(h2,'label','Winter',... 'callback',...

[...

'set(hl2,''checked'',''off''),',...

'set(hl2(5),''checked'',''on''),',... 'colormap(winter)']);

h3=uimenu(gcf,'label','坐标选项'); h31=uimenu(h3,'label','Axis on',...

'callback',... [...

'axis on,',... 'set(h31,''checked'',''on''),',...

'set(h32,''checked'',''off'')']); h32=uimenu(h3,'label','Axis off',...

'callback',... [...

'axis off,',... 'set(h32,''checked'',''on''),',...

'set(h31,''checked'',''off'')']);

实例41:除法计算器h=figure('toolbar','none',...

'position',[200 150 450 250],...

'name','实例41'); h1=uicontrol(gcf,'style','edit',...

'position',[80 200 100 20],...

'HorizontalAlignment','right',... 'callback',['m=get(h1,''string'');,',...

'a=str2num(m);']);

h2=uicontrol(gcf,'style','edit',... 'HorizontalAlignment','right',... 'position',[80 150 100 20],...

'callback',['n=get(h2,''string'');,',... 'b=str2num(n);']);

h3=uicontrol(gcf,'style','text',...

'string','被除数',... 'position',[80 230 100 20]);

h4=uicontrol(gcf,'style','edit',... 'position',[80 50 100 20]); h5=uicontrol(gcf,'style','pushbutton',... 'position',[80 100 100 20],... 'string','=',...

'callback',[...

'if b==0,',...

'h7=errordlg(''除数不能为0!'',''error'',''on'');,',...

'else,',...

'k=a/b;,',...

'c=num2str(k);,',... 'set(h4,''string'',c),',... 'end']);

h8=uicontrol(gcf,'style','text',...

'string','除数',... 'position',[80 175 100 20]);

h9=uicontrol(gcf,'style','text',...

'string','商',... 'position',[80 75 100 20]);

实例42:单选框的使用h0=figure('toolbar','none',...

'position',[200 150 450 250],...

'name','实例42'); x=0:0.5:2*pi;

y=sin(x);

plot(x,y) grid on

set(gcf,'toolbar','none') g=set(gca,'position',[0.2 0.2 0.6 0.6]); huidiao1=[... 'grid on,',... 'set(box_on,''value'',1),',...

'set(box_off,''value'',0),']; huidiao2=[...

'grid off,',... 'set(box_off,''value'',1),',...

'set(box_on,''value'',0),']; box_on=uicontrol(gcf,'style','radio',...

'position',[5 50 50 20],...

'string','grid on',...

'value',1,... 'callback',huidiao1);

box_off=uicontrol(gcf,'style','radio',... 'position',[5 20 50 20],...

'string','grid off',...

'value',0,... 'callback',huidiao2);

title('无线按钮的使用')

实例43:添加环境效果h0=figure('toolbar','none',...

'position',[198 56 450 468],...

'name','实例43');

h1=axes('parent',h0,... 'position',[0.15 0.45 0.7 0.5],...

'visible','off'); sphere

h=findobj('type','surface'); shading interp

axis equal l=light('position',[0 -2 1]); k(1)=get(h,'specularstrength'); k(2)=get(h,'diffusestrength'); k(3)=get(h,'specularexponent');

k(4)=get(h,'specularcolorreflectance');

u1=uimenu('parent',h0,...

'label','灯光效果',... 'tag','u1',...

'backgroundcolor',[0.75 0.75 0.75]); u11=uimenu('parent',u1,...

'label','gouraud',...

'tag','u11',...

'backgroundcolor',[0.75 0.75 0.75],... 'callback',[...

'set(u11,''checked'',''on'');,',...

'set(u12,''checked'',''off'');,',...

'set(h,''facelighting'',''gouraud'')']); u12=uimenu('parent',u1,...

'label','phong',...

'tag','u12',...

'backgroundcolor',[0.75 0.75 0.75],... 'callback',[...

'set(u11,''checked'',''off'');,',...

'set(u12,''checked'',''on'');,',...

'set(h,''facelighting'',''gouraud'')']); u2=uimenu('parent',h0,...

'label','背面灯光',...

'tag','u2',...

'backgroundcolor',[0.75 0.75 0.75]); u21=uimenu('parent',u2,...

'label','reverselit',...

'tag','u21',...

'checked','on',...

'backgroundcolor',[0.75 0.75 0.75],...

'callback',[... 'set(u21,''checked'',''on'');,',...

'set(u22,''checked'',''off'');,',...

'set(h,''backfacelighting'',''reverselit'')']); u22=uimenu('parent',u2,...

'label','reverselit',...

'tag','u22',...

'backgroundcolor',[0.75 0.75 0.75],... 'callback',[...

'set(u21,''checked'',''off'');,',...

'set(u22,''checked'',''on'');,',...

'set(h,''backfacelighting'',''reverselit'')']); s1=uicontrol('parent',h0,... 'units','points',...

'style','slider',...

'tag','s1',...

'min',0,...

'max',1,...

'value',k(1),...

'position',[20 80 100 15],...

'callback',[... 's1value=get(s1,''value'');,',...

'set(h,''specularstrength'',s1value)']); t1=uicontrol('parent',h0,...

'units','points',...

'style','text',...

'tag','t1',...

'string','镜面反射强度',... 'position',[20 97 100 15]);

s2=uicontrol('parent',h0,... 'units','points',...

'style','slider',...

'tag','s2',...

'min',0,...

'max',1,... 'value',k(2),...

'position',[20 30 100 15],...

'callback',[... 's2value=get(s2,''value'');,',...

'set(h,''diffusestrength'',s2value)']); t2=uicontrol('parent',h0,...

'units','points',...

'style','text',...

'tag','t2',...

'string','漫反射强度',... 'position',[20 47 100 15]);

s3=uicontrol('parent',h0,... 'units','points',...

'style','slider',...

'tag','s3',...

'min',0.1,...

'max',1,...

'value',k(3)/20,...

'position',[220 80 100 15],...

'callback',[... 's3value=get(s3,''value'')+eps;,',...

'set(h,''specularexponent'',20*s3value)']); t3=uicontrol('parent',h0,...

'units','points',...

'style','text',...

'tag','t3',...

'string','镜面指数',... 'position',[220 97 100 15]);

s4=uicontrol('parent',h0,... 'units','points',...

'style','slider',...

'tag','s4',...

'min',0,...

'max',1,...

'value',k(4),...

'position',[220 30 100 15],...

'callback',[... 's4value=get(s4,''value'');,',...

'set(h,''specularcolorreflectance'',s4value)']); t4=uicontrol('parent',h0,... 'units','points',...

'style','text',...

'tag','t1',...

'string','镜面颜色反射比',... 'position',[220 47 100 15]);

b1=uicontrol('parent',h0,... 'units','points',...

'style','pushbutton',...

'tag','b1',...

'string','关闭',...

'position',[145 45 50 30],...

'callback','close');

实例44:改变坐标轴范围h0=figure('toolbar','none',...

'position',[198 56 408 468],...

'name','实例44');

h1=axes('parent',h0,... 'position',[0.15 0.45 0.7 0.5],... 'visible','on'); e1=uicontrol('parent',h0,...

'style','edit',...

'string',1,... 'position',[50 120 50 20]);

t1=uicontrol('parent',h0,... 'style','text',...

'string','X轴最小值',... 'position',[35 150 80 20]);

e2=uicontrol('parent',h0,... 'style','edit',...

'string',5,...

'position',[50 60 50 20]); t2=uicontrol('parent',h0,...

'style','text',...

'string','X轴最大值',...

'position',[35 90 80 20]); e3=uicontrol('parent',h0,...

'style','edit',...

'string',1,... 'position',[150 120 50 20]);

t3=uicontrol('parent',h0,...

'style','text',...

'string','Y轴最小值',... 'position',[135 150 80 20]);

e4=uicontrol('parent',h0,... 'style','edit',...

'string',5,... 'position',[150 60 50 20]);

t4=uicontrol('parent',h0,... 'style','text',...

'string','Y轴最大值',... 'position',[135 90 80 20]);

e5=uicontrol('parent',h0,... 'style','edit',...

'string',20,... 'position',[250 120 50 20]);

matlab实用教程100例

matlab 实用程序百 例 1-32 就是:图形应用篇33-66 就是:界面设计篇 67-84 就是:图形处理篇 85-100 就是:数值分析篇实例1:三角函数曲线(1) function shili01 h0=figure('toolbar','none', 、、、 'position',[198 56 350 300], 、、、'name','实例01'); h1=axes('parent',h0,、、、 'visible','off'); x=-pi:0 、05:pi; y=sin(x); plot(x,y); xlabel(' 自变量X'); ylabel(' 函数值Y'); title('SIN( ) 函数曲线'); grid on 实例2:三角函数曲线(2) function shili02 h0=figure('toolbar','none', 、、、 'position',[200 150 450 350], 、、、'name',实例02'); x=-pi:0 、05:pi; y=sin(x)+cos(x); plot(x,y,'-*r','linewidth',1); grid on xlabel(' 自变量X'); ylabel(' 函数值Y'); title(' 三角函数'); 实例3:图形的叠加function shili03 h0=figure('toolbar','none', 、、、 'position',[200 150 450 350], 、、、 'name','实例03'); x=-pi:0 、05:pi; y1=sin(x); y2=cos(x); plot(x,y1, 、、、 I *r l 、、、x,y2, 、、、'--og'); grid on xlabel(' 自变量X'); ylabel(' 函数值Y'); title(' 三角函数'); 实例4:双y 轴图形的绘制 function shili04 h0=figure('toolbar','none', 、、、 'position',[200 150 450 250], 、、、'name',实例04'); x=0:900;a=1000;b=0 、005; y1=2*x; y2=cos(b*x); [haxes,hline1,hline2]=plotyy(x,y1,x,y2,'semilogy','plot'); axes(haxes(1)) ylabel('semilog plot'); axes(haxes(2)) ylabel('linear plot'); 实例5:单个轴窗口显示多个图形 function shili05 h0=figure('toolbar','none', 、、、

数学建模常用软件

数学建模常用软件有哪些哈 MatlabMathematicalingoSAS详细介绍:数学建模软件介绍一般来说学习数学建模,常用的软件有四种,分别是:matlab、lingo、Mathematica和SAS下面简单介绍一下这四种。 1.MA TLAB的概况MA TLAB是矩阵实验室(Matrix Laboratory)之意。除具备卓越的数值计算能力外,它还提供了专业水平的符号计算,文字处理,可视化建模仿真和实时控制等功能。MATLAB的基本数据单位是矩阵,它的指令表达式与数学,工程中常用的形式十分相似,故用MATLAB来解算问题要比用C,FORTRAN等语言完相同的事情简捷得多. 当前流行的MA TLAB 5.3/Simulink 3.0包括拥有数百个内部函数的主包和三十几种工具包(Toolbox).工具包又可以分为功能性工具包和学科工具包.功能工具包用来扩充MATLAB的符号计算,可视化建模仿真,文字处理及实时控制等功能.学科工具包是专业性比较强的工具包,控制工具包,信号处理工具包,通信工具包等都属于此类. 开放性使MATLAB广受用户欢迎.除内部函数外,所有MA TLAB主包文件和各种工具包都是可读可修改的文件,用户通过对源程序的修改或加入自己编写程序构造新的专用工具包. 2.Mathematica的概况Wolfram Research 是高科技计算机运算( Technical computing )的先趋,由复杂理论的发明者Stephen Wolfram 成立于1987年,在1988年推出高科技计算机运算软件Mathematica,是一个足以媲美诺贝尔奖的天才产品。Mathematica 是一套整合数字以及符号运算的数学工具软件,提供了全球超过百万的研究人员,工程师,物理学家,分析师以及其它技术专业人员容易使用的顶级科学运算环境。目前已在学术界、电机、机械、化学、土木、信息工程、财务金融、医学、物理、统计、教育出版、OEM 等领域广泛使用。Mathematica 的特色·具有高阶的演算方法和丰富的数学函数库和庞大的数学知识库,让Mathematica 5 在线性代数方面的数值运算,例如特征向量、反矩阵等,皆比Matlab R13做得更快更好,提供业界最精确的数值运算结果。·Mathematica不但可以做数值计算,还提供最优秀的可设计的符号运算。·丰富的数学函数库,可以快速的解答微积分、线性代数、微分方程、复变函数、数值分析、机率统计等等问题。·Mathematica可以绘制各专业领域专业函数图形,提供丰富的图形表示方法,结果呈现可视化。·Mathematica可编排专业的科学论文期刊,让运算与排版在同一环境下完成,提供高品质可编辑的排版公式与表格,屏幕与打印的自动最佳化排版,组织由初始概念到最后报告的计划,并且对txt、html、pdf 等格式的输出提供了最好的兼容性。·可与C、C++ 、Fortran、Perl、Visual Basic、以及Java 结合,提供强大高级语言接口功能,使得程序开发更方便。·Mathematica本身就是一个方便学习的程序语言。Mathematica提供互动且丰富的帮助功能,让使用者现学现卖。强大的功能,简单的操作,非常容易学习特点,可以最有效的缩短研发时间。 3.lingo的概况LINGO则用于求解非线性规划(NLP—NON—LINEAR PROGRAMMING)和二次规则(QP—QUARATIC PROGRAMING)其中LINGO 6.0学生版最多可版最多达300个变量和150个约束的规则问题,其标准版的求解能力亦再10^4量级以上。虽然LINDO和LINGO不能直接求解目标规划问题,但用序贯式算法可分解成一个个LINDO和LINGO能解决的规划问题。模型建立语言和求解引擎的整合LINGO是使建立和求解线性、非线性和整数最佳化模型更快更简单更有效率的综合工具。LINGO提供强大的语言和快速的求解引擎来阐述和求解最佳化模型。■简单的模型表示LINGO可以将线性、非线性和整数问题迅速得予以公式表示,并且容易阅读、了解和修改。■方便的数据输入和输出选择LINGO建立的模型可以直接从数据库或工作表获取资料。同样地,LINGO可以将求解结果直接输出到数据库或工作表。■强大的求解引擎LINGO内建的求解引擎有线性、非线性(convex and nonconvex)、二次、二次

数学建模(Matlab)

数学规划作业(MatLab) 1、某厂向用户提供发动机,合同规定,第一、二、三季度末分别交货40台、60台、80台.每季度的生产费用为()2 =+ f x ax bx (单位:元), 其中x是该季度生产的台数.若交货后有剩余,可用于下季度交货,但需支付存储费,每台每季度c元.已知工厂每季度最大生产能力为100台,第一季度开始时无存货,设a=50、b=0.2、c=4,问:工厂应如何安排生产计划,才能既满足合同又使总费用最低.讨论a、b、c变化对计划的影响,并作出合理的解释. 解: 问题的分析和假设: 分析: 问题的关键在于由于工厂的生产能力足以满足每个季度用户的需求,但是为了使总费用最少,那么利用每个季度生产费用的不同,可用利用上个生产费用低的季度多生产来为下个季度进行准备,前提是本月节省下的费用减去总的发动机存储费用还有剩余,这样生产才有价值,才可能满足合同的同时又能使总费用最低。基本假设:1工厂的生产能力不受外界环境因素影响。2为使总费用最低,又能满足合同要求,各个季度之间的生产数量之间是有联系的。3第一季度开始时无存货。4工厂每季度的生关费用与本季度生产的发动机台数有关。5生产要按定单的数量来进行,生产的数量应和订单的数量相同,以避免生产出无用的机器。 符号规定:X1―――第一季度生产发动机的数量 X2―――第二季度生产发动机的数量

X3―――第三季度生产发动机的数量 建模: 1.三个季度发动机的总的生产量为180台。 2.每个季度的生产量和库存机器的数量之和要大于等于本季度的交货数量。 3.每个月的生产数量要符合工厂的生产能力。 4.将实际问题转化为非线性规划问题,建立非线性规划模型 目标函数 min f(x)=50(x1+x2+x3)+0.2(x12+x22+x32)+4(x1-40)+4(x1+x2-100) 整理,得 min f(x)=50(x1+x2+x3)+0.2(x12+x22+x32)+4(2x1+x2-140) 约束函数s.t x1+x2≥100; x1+x2+x3=180; 40≤x1≤100; 0≤x2≤100; 0≤x3≤100; 求解的Matlab程序代码: M-文件 fun.m: function f=fun (x); f=50*(x(1)+x(2)+x(3))+0.2*(x(1)^2+x(2)^2+x(3)^2)+4*(2*x(1) +x(2)-140)主程序fxxgh.m:

2015研究生数学建模MATLAB程序(完整版)

′ú??ò?£o % ?a?ü1y3ì?°??ò??ü??í3?? clear clc fid1=fopen('mingwen1.txt','r'); str1=fgets(fid1); fclose(fid1); fid2=fopen('jiemihou1.txt','r'); str2=fgets(fid2); fclose(fid2); % é?è¥μ¥′ê????μ?????oí±êμ?·?o? ad=find(str2==',');str2(ad)='';ad=find(str2=='.');str2(ad)='';ad=find(str2==';') ;str2(ad)=''; ad=find(str2=='''');str2(ad)='';ad=find(str2=='?');str2(ad)='';ad=find(str2=='£o');str2(ad)=''; ad=find(str2=='"');str2(ad)='';ad=find(str2=='-');str2(ad)='';ad=find(str2= ='/');str2(ad)=''; ad=find(str2==' ');str2(ad)=''; for i=0:25; ad=find(str1=='A'+i);str1(ad)='a'+i; end for i=0:25; ad=find(str2=='A'+i);str2(ad)='a'+i; end n1(1,26)=0; n2(1,26)=0; n1(1)=sum(str1=='a');n2(1)=sum(str2=='a'); n1(2)=sum(str1=='b');n2(2)=sum(str2=='b'); n1(3)=sum(str1=='c');n2(3)=sum(str2=='c'); n1(4)=sum(str1=='d');n2(4)=sum(str2=='d'); n1(5)=sum(str1=='e');n2(5)=sum(str2=='e'); n1(6)=sum(str1=='f');n2(6)=sum(str2=='f'); n1(7)=sum(str1=='g');n2(7)=sum(str2=='g'); n1(8)=sum(str1=='h');n2(8)=sum(str2=='h'); n1(9)=sum(str1=='i');n2(9)=sum(str2=='i'); n1(10)=sum(str1=='j');n2(10)=sum(str2=='j'); n1(11)=sum(str1=='k');n2(11)=sum(str2=='k'); n1(12)=sum(str1=='l');n2(12)=sum(str2=='l'); n1(13)=sum(str1=='m');n2(13)=sum(str2=='m'); n1(14)=sum(str1=='n');n2(14)=sum(str2=='n'); n1(15)=sum(str1=='o');n2(15)=sum(str2=='o');

MATLAB及在数学建模中的应用

第1讲MATLAB及 在数学建模中的应用 ? MatLab简介及基本运算?常用计算方法 ?应用实例

一、 MatLab简介及基本运算 1.1 MatLab简介 1.2 MatLab界面 1.3 MatLab基本数学运算 1.4 MatLab绘图

1.1 MatLab简介?MATLAB名字由MATrix和 LABoratory 两词组成。20世纪七十年代后期, 美国新墨西哥大学计算机科学系主任Cleve Moler教授为减轻学生编程负担,为学生设计了一组调用LINPACK和EISPACK库程序的“通俗易用”的接口,此即用FORTRAN编写的萌芽状态的MATLAB。

?经几年的校际流传,在Little的推动下,由Little、Moler、Steve Bangert合作,于1984年成立了MathWorks公司,并把MATLAB正式推向市场。从这时起,MATLAB的内核采用C语言编写,而且除原有的数值计算能力外,还新增了数据图视功能。

?1997年春,MATLAB5.0版问世,紧接着是5.1、5.2、5.3、6.0、6.1、6.5、7.0版。现今的MATLAB拥有更丰富的数据类型和结构、更友善的面向对象、更加快速精良的图形可视、更广博的数学和数据分析资源、更多的应用开发工具。 ?20世纪九十年代的时候,MATLAB已经成为国际控制界公认的标准计算软件。

?MATLAB具有用法简易、可灵活运用、程式结构强又兼具延展性。以下为其几个特色: ①可靠的数值运算和符号计算。在MATLAB环境中,有超过500种数学、统计、科学及工程方面的函 数可使用。 ②强大的绘图功能。 MATLAB可以绘制各种图形,包括二维和三维图形。 ③简单易学的语言体系。 ④为数众多的应用工具箱。

matlab实用程序百例1

下载地址:https://www.360docs.net/doc/567991276.html,/viewthread.php?tid=2981 1-32是:图形应用篇 33-66是:界面设计篇 67-84是:图形处理篇 85-100是:数值分析篇 实例1:三角函数曲线(1) function shili01 h0=figure('toolbar','none',... 'position',[198 56 350 300],... 'name','实例01'); h1=axes('parent',h0,... 'visible','off'); x=-pi:0.05:pi; y=sin(x); plot(x,y); xlabel('自变量X'); ylabel('函数值Y'); title('SIN( )函数曲线'); grid on 实例2:三角函数曲线(2) function shili02 h0=figure('toolbar','none',... 'position',[200 150 450 350],... 'name','实例02'); x=-pi:0.05:pi; y=sin(x)+cos(x); plot(x,y,'-*r','linewidth',1); grid on xlabel('自变量X'); ylabel('函数值Y'); title('三角函数'); 实例3:图形的叠加

function shili03 h0=figure('toolbar','none',... 'position',[200 150 450 350],... 'name','实例03'); x=-pi:0.05:pi; y1=sin(x); y2=cos(x); plot(x,y1,... '-*r',... x,y2,... '--og'); grid on xlabel('自变量X'); ylabel('函数值Y'); title('三角函数'); 实例4:双y轴图形的绘制 function shili04 h0=figure('toolbar','none',... 'position',[200 150 450 250],... 'name','实例04'); x=0:900;a=1000;b=0.005; y1=2*x; y2=cos(b*x); [haxes,hline1,hline2]=plotyy(x,y1,x,y2,'semilogy','plot'); axes(haxes(1)) ylabel('semilog plot'); axes(haxes(2)) ylabel('linear plot'); 实例5:单个轴窗口显示多个图形 function shili05 h0=figure('toolbar','none',... 'position',[200 150 450 250],... 'name','实例05'); t=0:pi/10:2*pi; [x,y]=meshgrid(t); subplot(2,2,1) plot(sin(t),cos(t)) axis equal subplot(2,2,2) z=sin(x)-cos(y); plot(t,z)

数学建模matlab例题参考及练习

数学实验与数学建模 实验报告 学院: 专业班级: 姓名: 学号: 完成时间:年月日

承 诺 书 本人承诺所呈交的数学实验与数学建模作业都是本人通过学习自行进行编程独立完成,所有结果都通过上机验证,无转载或抄袭他人,也未经他人转载或抄袭。若承诺不实,本人愿意承担一切责任。 承诺人: 年 月 日 数学实验学习体会 (每个人必须要写字数1200字以上,占总成绩的20%) 练习1 一元函数的图形 1. 画出x y arcsin =的图象. 2. 画出x y sec =在],0[π之间的图象. 3. 在同一坐标系中画出x y =,2x y =,3 x y = ,3x y =,x y =的图象. 4. 画出3 2 3 2)1()1()(x x x f + +-=的图象,并根据图象特点指出函数)(x f 的奇偶性. 5. 画出)2ln(1++=x y 及其反函数的图象. 6. 画出3 21+=x y 及其反函数的图象.

练习2 函数极限 1.计算下列函数的极限. (1) x x x 4 cos 1 2 sin 1 lim 4 - + π → . 程序: sym x; f=(1+sin(2*x))/(1-cos(4*x)); limit(f,x,pi/4) 运行结果: lx21 ans = 1 (2). 程序: sym x; f=(1+cos(x))^(3*sec(x)); limit(f,x,pi/2) 运行结果: lx22 ans = exp(3) (3) 2 2 ) 2 ( sin ln lim x x x - π π → . 程序: sym x; f=log(sin(x))/(pi-2*x)^2; limit(f,x,pi/2) 运行结果: lx23 ans = -1/8 (4) 2 1 2 lim x x e x →. 程序: x x x sec 3 2 ) cos 1( lim+ π →

数学建模MATLAB程序汇总

建模MATLAB程序汇总 求特征值、特征向量、权向量 A=input('A='); E=eig(A) [V,D]=eig(A) t=max(E); disp(t); for i=1:1:3 if E(i)==t; m=i; end end X=V(:,m); mt=X./sum(X); disp(mt) 求π n=1;s=0; while 1/(2*n-1)>10^(-6) s=s+(-1)^(n+1)/(2*n-1); n=n+1; end pai=4*s 求e n=1;s=1; while 1/prod(1:n)>10^(-6) s=s+1/prod(1:n); n=n+1; end e=s 回归分析、 x=[143 145 146 147 149 150 153 154 155 156 157 158 159 160 162 164]'; Y=[88 85 88 91 92 93 93 95 96 98 97 96 98 99 100 102]'; X=[ones(16,1) x]; [b,bint,r,rint,stats]=regress(Y,X,0.025); b,bint,stats rcoplot(r,rint) z=b(1)+b(2)*x plot(x,Y,'k+',x,z,'r') 回归曲线 x=[2:16]; y=[6.42 8.20 9.58 9.50 9.70 10 9.93 09.99 10.49 10.59 10.60 10.80 10.60 10.90 10.76]; x1=1./x;

y1=log(y); p=polyfit(x1,y1,1) a=exp(p(2)) b=p(1) z=a.*exp(b./x) plot(x,y,'k+',x,z,'r') 回归预测 x=[20 25 30 35 40 45 50 55 60 65]'; Y=[13.2 15.1 16.4 17.1 17.9 18.7 19.6 21.2 22.5 24.3]'; X=[ones(10,1) x]; [b,bint,r,rint,stats]=regress(Y,X,0.05); b,bint,stats rcoplot(r,rint) z=b(1)+b(2)*x rstool(x,Y,'purequadratic') 灰色GM(1,1) clc,clear x0=[8438.73 9398.53 9959.17 10949.99 11145.92 11800 12700]; n=length(x0); lamda=x0(1:n-1)./x0(2:n) range=minmax(lamda) x1=cumsum(x0) for i=2:n z(i)=0.5*(x1(i)+x1(i-1)); end B=[-z(2:n)',ones(n-1,1)]; Y=x0(2:n)'; u=B\Y x=dsolve('Dx+a*x=b','x(0)=x0'); x=subs(x,{'a','b','x0'},{u(1),u(2),x1(1)}); yuce1=subs(x,'t',[0:n-1]); digits(6),y=vpa(x) %为提高预测精度,先计算预测值,再显示微分方程的解yuce=[x0(1),diff(yuce1)] epsilon=x0-yuce %计算残差 delta=abs(epsilon./x0) %计算相对误差 rho=1-(1-0.5*u(1))/(1+0.5*u(1))*lamda %计算级比偏差值 求余 for n=1:5000 k=n^3; if rem(k,10000)==8888 n end end 人口预测模型

数学建模章绍辉版第四章作业

第四章作业 第二题: 针对严重的交通情况,国家质量监督检验检疫局发布的国家标准,车辆驾驶人员血液中的酒精含量大于或等于20mg/100ml,小于80mg/100ml 为饮酒驾车,血液中的酒精含量大于或等于80mg/100ml 的为醉酒驾车。 下面分别考虑大李在很短时间内和较长时间内(如2个小时)喝了三瓶啤酒,多长时间内驾车就会违反新的国家标准。 1、 问题假设 大李在短时间内喝下三瓶啤酒后,酒精先从吸收室(肠胃)吸收进中心室(血液和体液),然后从中心室向体外排除,忽略喝酒的时间,根据生理学知识,假设 (1) 吸收室在初始时刻t=0时,酒精量立即为 32 D ;在任意时刻,酒精从吸收室吸收进中心室的速率(吸收室在单位时间内酒精含量的减少量)与吸收室的酒精含量成正比,比例系数为1k ; (2) 中心室的容积V 保持不变;在初始时刻t=0时,中心室的酒精含量为0;在任意时 刻,酒精从中心室向体外排除的速率(中心室在单位时间内酒精含量的减少量)与 中心室的酒精含量成正比,比例系数为2k ; (3) 在大李适度饮酒没有酒精中毒的前提下,假设1k 和2k 都是常量,与饮酒量无关。 2、 符号说明 酒精量是指纯酒精的质量,单位是毫克; 酒精含量是指纯酒精的浓度,单位是毫克/百毫升; ~t 时刻(小时) ; ()~x t 在时刻t 吸收室(肠胃)内的酒精量(毫克) ; 0~D 两瓶酒的酒精量(毫克); (t)~c 在时刻t 吸收室(血液和体液)的酒精含量(毫克/百毫升) ; 2()~c t 在时刻t 中心室(血液和体液)的酒精含量(毫克/百毫升); ~V 中心室的容积(百毫升) ; 1~k 酒精从吸收室吸收进中心室的速率系数(假设其为常数2.0079); 2~k 酒精从中心室向体外排除的速率系数(假设其为常数0.1855); 3~k 在短时间喝下三瓶酒的假设下是指短时间喝下的三瓶酒的酒精总量除以中心室体积, 即03/2D V ;而在较长时间内(2小时内)喝下三瓶酒的假设下就特指03/4D V .

MATLAB数学实验一百例题解.docx

一元函数微分学 实验 1 一元函数的图形(基础实验) 实验目的 通过图形加深对函数及其性质的认识与理解 , 掌握运用函数的图形来观察和分析 函数的有关特性与变化趋势的方法 , 建立数形结合的思想 ; 掌握用 Matlab 作平面曲线图性的方 法与技巧 . 初等函数的图形 2 作出函数 y tan x 和 y cot x 的图形观察其周期性和变化趋势 . 解:程序代码 : >> x=linspace(0,2*pi,600); t=sin(x)./(cos(x)+eps); plot(x,t);title('tan(x)');axis ([0,2*pi,-50,50]); 图象 : 程序代码 : >> x=linspace(0,2*pi,100); ct=cos(x)./(sin(x)+eps); plot(x,ct);title('cot(x)');axis ([0,2*pi,-50,50]); 图象 : 4 在区间 [ 1,1] 画出函数 y sin 1 的图形 . x 解:程序代码 : >> x=linspace(-1,1,10000); y=sin(1./x); plot(x,y); axis([-1,1,-2,2]) 图象 : 二维参数方程作图 6 画出参数方程 x( t ) cos t cos 5t 的图形: y(t) sin t cos 3t 解:程序代码 : >> t=linspace(0,2*pi,100); plot(cos(t).*cos(5*t),sin(t).*cos(3*t)); 图象 : 极坐标方程作图 8 作出极坐标方程为 r e t / 10 的对数螺线的图形 . 解:程序代码 : >> t=0::2*pi; r=exp(t/10); polar(log(t+eps),log(r+eps));

(完整版)蚁群算法matlab程序实例整理

function [y,val]=QACS tic load att48 att48; MAXIT=300; % 最大循环次数 NC=48; % 城市个数 tao=ones(48,48);% 初始时刻各边上的信息最为1 rho=0.2; % 挥发系数 alpha=1; beta=2; Q=100; mant=20; % 蚂蚁数量 iter=0; % 记录迭代次数 for i=1:NC % 计算各城市间的距离 for j=1:NC distance(i,j)=sqrt((att48(i,2)-att48(j,2))^2+(att48(i,3)-att48(j,3))^2); end end bestroute=zeros(1,48); % 用来记录最优路径 routelength=inf; % 用来记录当前找到的最优路径长度 % for i=1:mant % 确定各蚂蚁初始的位置 % end for ite=1:MAXIT for ka=1:mant %考查第K只蚂蚁 deltatao=zeros(48,48); % 第K只蚂蚁移动前各边上的信息增量为零 [routek,lengthk]=travel(distance,tao,alpha,beta); if lengthk

matlab在数学建模中的应用

Matlab在数学建模中的应用 数学建模是通过对实际问题的抽象和简化,引入一些数学符号、变量和参数,用数学语言和方法建立变量参数间的内在关系,得出一个可以近似刻画实际问题的数学模型,进而对其进行求解、模拟、分析检验的过程。它大致分为模型准备、模型假设、模型构成、模型求解、模型分析、模型检验及应用等步骤。这一过程往往需要对大量的数据进行分析、处理、加工,建立和求解复杂的数学模型,这些都是手工计算难以完成的,往往在计算机上实现。在目前用于数学建模的软件中,matlab 强大的数值计算、绘图以及多样化的工具箱功能,能够快捷、高效地解决数学建模所涉及的众多领域的问题,倍受数学建模者的青睐。 1 Matlab在数学建模中的应用 下面将联系数学建模的几个环节,结合部分实例,介绍matlab 在数学建模中的应用。 1.1 模型准备阶段 模型准备阶段往往需要对问题中的给出的大量数据或图表等进行分析,此时matlab的数据处理功能以及绘图功能都能得到很好的应用。 1.1.1 确定变量间关系 例1 已知某地连续20年的实际投资额、国民生产总值、物价指数的统计数据(见表),由这些数据建立一个投资额模型,根据对未来国民生产总值及物价指数的估计,预测未来的投资额。

表1 实际投资额、国民生产总值、物价指数的统计表 记该地区第t年的投资为z(t),国民生产总值为x(t),物价指数为y(t)。 赋值: z=[90.9 97.4 113.5 125.7 122.8 133.3 149.3 144.2 166.4 195 229.8 228.7 206.1 257.9 324.1 386.6 423 401.9 474.9 424.5]' x=[596.7 637.7 691.1 756 799 873.4 944 992.7 1077.6 1185.9 1326.4 1434.2 1549.2 1718 1918.3 2163.9 2417.8 2631.6 2954.7 3073]' y=[0.7167 0.7277 0.7436 0.7676 0.7906 0.8254 0.8679 0.9145 0.9601 1 1.0575 1.1508 1.2579 1.3234 1.4005 1.5042 1.6342 1.7842 1.9514 2.0688]' 先观察x与z之间,y与z之间的散点图 plot(x,z,'*') plot(y,z,'*') 由散点图可以看出,投资额和国民生产总值与物价指数都近似呈

matlab数学建模实例

第四周 3. 中的三个根。 ,在求8] [0,041.76938.7911.1-)(2 3=-+=x x x x f function y=mj() for x0=0:0.01:8 x1=x0^3-11.1*x0^2+38.79*x0-41.769; if (abs(x1)<1.0e-8) x0 end end 4.分别用简单迭代法、埃特金法、牛顿法求解方程,并比较收敛性与收敛速度(ε分别取10-3、10-5、10-8)。 简单迭代法: function y=jddd(x0) x1=(20+10*x0-2*x0^2-x0^3)/20; k=1; while (abs(x1-x0)>=1.0e-3) x0=x1; x1=(20+10*x0-2*x0^2-x0^3)/20;k=k+1; end x1 k 埃特金法: function y=etj(x0) x1=(20-2*x0^2-x0^3)/10; x2=(20-2*x1^2-x1^3)/10; x3=x2-(x2-x1)^2/(x2-2*x1+x0); k=1; while (abs(x3-x0)>=1.0e-3) x0=x3; x1=(20-2*x0^2-x0^3)/10; x2=(20-2*x1^2-x1^3)/10; x3=x2-(x2-x1)^2/(x2-2*x1+x0);k=k+1; end 2 ,020102)(023==-++=x x x x x f

x3 k 牛顿法: function y=newton(x0) x1=x0-fc(x0)/df(x0); k=1; while (abs(x1-x0)>=1.0e-3) x0=x1; x1=x0-fc(x0)/df(x0);k=k+1; end x1 k function y=fc(x) y=x^3+2*x^2+10*x-20; function y=df(x) y=3*x^2+4*x+10; 第六周 1.解例6-4(p77)的方程组,分别采用消去法(矩阵分解)、Jacobi迭代法、Seidel迭代法、松弛法求解,并比较收敛速度。 消去法: x=a\d 或 [L,U]=lu(a); x=inv(U)inv(L)d Jacobi迭代法: function s=jacobi(a,d,x0) D=diag(diag(a)); U=-triu(a,1); L=-tril(a,-1); C=inv(D); B=C*(L+U); G=C*d; s=B*x0+G; n=1; while norm(s-x0)>=1.0e-8 x0=s; s=B*x0+G;

基于MATLAB的光伏电池通用数学模型

本文由qpadm贡献 pdf文档可能在WAP端浏览体验不佳。建议您优先选择TXT,或下载源文件到本机查看。 第 25 卷第 4 期 2009 年 4 月 电 力 For personal use only in study and research; not for commercial use 科 学 与 For personal use only in study and research; not for commercial use 工 程 Vol.25, No.4 Apr., 2009 11 For personal use only in study and research; not for commercial use Electric Power Science and Engineering 基于 MATLAB 的光伏电池通用数学模型 王长江 For personal use only in study and research; not for commercial use (华北电力大学电气与电子工程学院,北京 102206)摘要:针对光伏电池输出特性具有强烈的非线性,根据太阳能电池的直流物理模型,利用 MATLAB 建立了太阳能光伏阵列通用的仿真模型。利用此模型,模拟任意环境、太阳辐射强度、电池板参数、电池板串并联方式下的光伏阵列 I-V 特性。模型内部参数经过优化,较好地反应了电池实际特性。模型带有最大功率点跟踪功能,能很好地实现光伏发电系统最佳工作点的跟踪。关键词:光伏电池;MPPT;I-V 特性中图分类号:TM615 文献标识码:A 引 言 1 光伏电池特性 随着化石能源的消耗,全球都在面临能源危机,太阳能依靠其清洁、分布广泛等特点成为当今发展速度居第二位的能源 [1] 。光伏阵列由多个单体太阳能电池进行串并联封装而成,是光伏发电的能源供给中心,其 I V 特性曲线随日照强度和太阳能电池温度变化,即 I=f ( V, S, T ) 。目前而厂家通常仅为用户提供标准测试的短路电流 I sc 、开路电压 Voc、最大功率点电流 I m 、最大功率点电压 V m 值,所以如何根据已有的标准测试数据来仿真光伏阵列在不同日照、温度下的 I V,P V 特性曲线,在光伏发电系统分析研究中显得至关重要 [2] 。文献 [ 3~4 ] 介绍了一些光伏发电相关的仿真模型,但这些模型都需要已知一些特定参数,使得分析研究有一些困难。文献 [ 5 ] 介绍了经优化的光伏电池模型,但不能任意改变原始参数。文献 [ 6 ] 给出了光伏电池的原理模型,但参数选用典型值,会造成较大的误差。本文考虑工程应用因素,基于太阳能电池的物理模型,建立了适用于任何条件下的工程用光伏电池仿真模型。

#自学MATLAB很好的资料,很多,全部免费

自学MATLAB很好的资料,很多,全部免费! 默认分类 2009-06-05 23:22:37 阅读197 评论0 字号:大中小订阅【MATLAB下载、安装、使用】 matlab 7.0 完整版 iso [0.99G] 下载! Matlab绿色迷你版.rar(仅6M大小) Matlab中asv文件到底是什么东西? Matlab 启动后一直初始化不动,cpu 90%以上的解决 安装matlab 7.0 时缺少mwinstall.dll的解决方法 解决MATLAB符号工具箱与安全卫士冲突方法 Matlab2009a下载地址 Matlab R2009a安装注册方法(图文版) AMD处理器上安装MATLAB,打开之后一闪自动关闭的解决办法 MATLAB 基础应用 哈工大matlab基础及应用讲义PPT 《MATLAB 7.0基础教程》-清华大学出版社 Matlab实用程序百例源程序 Matlab官方教程《Learn Matlab7.0(学生版本)》 张志涌《精通matlab6.5 (北航)》pdf电子书下载 《MATLAB基础与应用实例集粹》源程序打包下载 精通MATLAB综合辅导与指南-西安交大(word版) /viewthread.php?tid=133 MATLAB基础知识入门(ppt),对新手应该很有用的! 王丽萍-matlab课件(包含许多M文件代码)

自学Matlab必备的60个小程序代码 我也来发点东西:《精通 MATLAB 科学计算》 MATLAB 数学运算 Matlab偏微分方程工具箱应用简介 MATLAB数据分析与多项式计算 ppt讲义 王能超《计算方法:算法设计及其MATLAB实现》pdf电子书 数值分析及其MATLAB实现(附光盘MATLAB6.X\7.X版)随书光盘下载Matlab求解微分方程——个人总结 微分方程转换为一阶显示微分方程组方法 Matlab中几个数值积分函数的比较和优缺点 MATLAB GUI应用 用GUIDE创建GUI视频教程简单明了 GUI演示实例:自制简易计算器 基于Matlab GUI的扫雷游戏 很好的GUI学习开发经验 GUI中各种控件的特征属性的意义和应用 GUI演示实例:主成分分析GUI代码---很经典 Matlab GUI 编程(适用于Matlab的初学者) MATLAB GUI新手备忘录 GUI新手之教你读懂GUI的M文件 MATLAB 图像处理 MATLAB图像处理命令(pdf)(很全,很有用)

数学实验与数学建模(matlab在建模中的应用)

数学实验与数学建模 学习目标 1.掌握利用Matlab软件进行了相关的数学运算的方法. 2.以软件辅助来完成数学实验. 3.了解数学建模思想方法,能够对一些简单问题建立数学模型求解分析. 教学要求 Matlab是Mathworks公司推出的用于数值计算的交互式软件系统,具有强大的数值分析、矩阵运算、信号处理、图形显示和建模仿真功能. Matlab是“Matrix Laboratory”的缩写,意思是“矩阵实验室”,其强大的数据处理能力和丰富的工具箱使它的编程极为简单,因此,它成为科学家和工程技术人员解决实际问题的首选计算工具软件。 本章的第一节主要介绍Matlab软件的简单使用方法,从第二节到第六节在讲解Matlab 用于解决高等数学和线性代数中的相关计算的函数基础上, 通过一些简单的数学实验例题,让学生体会如何用Matlab辅助解决数学问题. 最后,通过一些与线性代数相关的数学建模实例,让学生掌握数学建模的简单方法,学会利用Matlab软件辅助解决实际问题,以培养学生良好的数学意识和数学素质. 6.1 Matlab环境及使用方法 6.1.1 Matlab窗口管理 Matlab启动后显示三个窗口,如图6.1所示。左上窗口为工作区间窗口,显示用户定义的变量及其属性类型及变量长度。工作区间窗口也可显示为当前目录窗口,显示Matlab 所使用的当前目录及该目录下的全部文件名。左下窗口为历史窗口,显示每个工作周期(指Matlab启动至退出的工作时间间隔)在命令窗口输入的全部命令,这些命令还可重新获取应用。右侧窗口为Matlab命令窗口,可在里面输入相关运算命令,完成相应计算。三个窗口中的记录除非通过Edit菜单下的清除操作,否则将一直保存。

(整理)matlab实例教程-比较实用.

实验一特殊函数与图形 一、问题背景与实验目的 二、相关函数(命令)及简介 三、实验内容 四、自己动手 一、问题背景与实验目的 著名的Riemann函数大家都很熟悉了,但是关于它的图像你是否清楚呢除了最上面那几点,其他都很难画吧你想不想看看下面那些“挤在一起”的点是怎样分布的呢还有几何中的马鞍面、单叶双曲面等是怎样由直线生成的,是不是也想目睹一下呢这些,都离不开绘图. 实际上绘图一直是数学中的一种重要手段,借助图形,往往可以化繁为简,使抽象的对象得到明白直观的体现.比如函数的基本性质,一个图形常可以使之一目了然,非常有效.它虽不能代替严格的分析与证明,但在问题的研究过程中,可以帮助研究人员节约相当一部分精力.此外,它还可以使计算、证明、建模等的结果得到更明白易懂的表现,有时,这比科学论证更有说服力.同时,数学的教学与学习过程也离不开绘图.借助直观的图形,常可以使初学者更容易接受新知识.如数学分析中有不少函数,其解析式着实让人望而生畏,即使对其性质作了详尽的分析,还是感到难明就里;但如果能看到它的图形,再配合理论分析,则问题可以迎刃而解.又如在几何的学习中,会遇到大量的曲线与曲面,也离不开图形的配合. 传统的手工作图,往往费力耗时,效果也不尽理想.计算机恰恰弥补了这个不足,使你可以方便地指定各种视角、比例、明暗,从各个角度进行观察.本实验通过对函数的图形表示和几个曲面(线)图形的介绍,一方面展示它们的特点,另一方面,也将就Matlab软件的作图功能作一个简单介绍.大家将会看到,Matlab 的作图功能非常强大. 二、相关函数(命令)及简介 1.平面作图函数:plot,其基本调用形式: plot(x,y,s) 以x作为横坐标,y作为纵坐标.s是图形显示属性的设置选项.例如:x=-pi:pi/10:pi; y=sin(x); plot(x,y,'--rh','linewidth',2,'markeredgecolor','b','markerfac ecolor','g')

相关文档
最新文档