MATLAB考试复习题及例题 联系客服

发布时间 : 星期日 文章MATLAB考试复习题及例题更新完毕开始阅读52fc78194a7302768e99391a

c. y’=-xsinx/cosy, y(2)=1

(2)求微分方程组 ? f ? ? f ? 2 g 的解。

dfdt??g??f?4? g , ? ?(3)求微分方程组 ? f f ? g 当初始条件为

dtdgf(0)=2,g(2)=5 时的解。

(4)练习使用单变量函数分析界面。

用命令 plot(x,y)绘制函数 y=cos(x)在两个周期内的图形。 x=0:0.01:2*pi; y=cos(x); plot(x,y)

在同一图形窗口中用命令 plot(x,y)绘出正弦余弦函数的图形。 x=0:0.01:2*pi; y=[sin(x);cos(x)]; plot(x,y)

用命令plot(Y)绘制矩阵 Y=[5 4 3 8 9 10;3 4 4 5 8 2 ;8 12 13 21 18 25 ;9 8 8 9 6 7]的图形。

Y=[5 4 3 8 9 10;3 4 4 5 8 2 ;8 12 13 21 18 25 ;9 8 8 9 6 7]; plot(Y) 用plot(Z)绘制图形。 x=0:pi/20:2*pi; Z=sin(x)+cos(x)*i

plot(Z)

等价于plot(real(Z),imag(Z))

用plot(x1,y1,x2,y2,…)在同一窗口中绘制多条曲线,且坐标和长度都不同。

t1=0:0.1:3*pi; t2=0:0.1:6;

plot(t1,sin(t1),t2,sqrt(t2)) 绘制正弦函数的对数坐标曲线。 t=0.1:0.1:3*pi; y=sin(t); figure(1) semilogx(t,y)

grid on %为图形窗口添加网格 figure(2) semilogy(t,y) figure(3) loglog(t,y)

用 plotyy 函数绘制双 y 轴图形。 t1=0:0.1:3*pi; t2=0:0.1:6; y1=sin(t1); y2=sqrt(t2);

plotyy(t1,y1,t2,y2,'semilogx') grid on

在同一图形窗口中用不同的绘图函数绘制同一函数曲线 y ? x 的双 y 轴图形。 x=0:0.1:6; y=sqrt(x);

plotyy(x,y,x,y,’semilogy’,’plot’) 用不同的线型和标注来绘制两条曲线。 t1=0:0.1:2*pi; t2=0:0.1:6; y1=sin(t1); y2=sqrt(t2);

plot(t1,y1,':hb',t2,y2,'--g')

用 subplot 函数把两种不同的图形综合在一个图形窗口中。 subplot(2,2,1) t=0.1:0.1:2*pi; y=sin(t); semilogx(t,y) grid on subplot(2,2,2) t=0:0.1:4*pi; y=sin(t);

plot(t,y) subplot(2,2,3) x=1:0.01:5; y=exp(x);

plotyy(x,y,x,y,’semilogx’,’plot’) subplot(2,2,4) x=1:0.1:10; y=sqrt(x); plot(x,y,’:rd’)

? x函数 z ? e ,定义区域为[-2,2]×[-2,2]。生成网格并

计算其网格点上的函数值。

[X,Y] = meshgrid(-2:2:2, -2:2:2); [X,Y] %将划分结果输出至矩阵 ans =

-2 0 2 -2 -2 -2

-2 0 2 0 0 0 -2 0 2 2 2 2

Z = X .* exp(-X.^2 - Y.^2); %计算网格点上的函数值赋予变量 Z Z =

?x2?y2