第一次试验
1。 画出公式y=cos(x)*(5=8*sin(x))+x*e –x 分别画在0—2x内取1000个的曲线图,和x=【-3,3】取0。01间隔的曲线图
x1=linspace(0,2*pi,100);
y1=cos(x1)。*(5+8*sin(x1))+x1.*exp(-x1);
subplot(2,1,1);
plot(x1,y1);
杭州电子科技大学x2=—3:0.01:3;
y2=cos(x2)。*(5+8*sin(x2))+x2。*exp(—x2);
subplot(2,1,2);
plot(x2,y2)
2。画出公式x=cos(t+a),y=sin(2t),其中a=0,π/6,π/3,π/2,在4个子图中画出曲线
t=-10:0.001:10;
c1=0;
x1=cos(t+c1);
y1=sin(2*t);
subplot(2,2,1);
plot(x1,y1);
c2=pi/6;
x2=cos(t+c2);
y2=sin(2*t);
subplot(2,2,2);
plot(x2,y2);
c3=pi/3;
x3=cos(t+c3);
y3=sin(2*t);
subplot(2,2,3);
plot(x3,y3);
c4=pi/2;
x4=cos(t+c4);
y4=sin(2*t);
subplot(2,2,4);
plot(x4,y4)
3。读取一幅彩图像,将其转变成灰度图像,将灰度图顺时针旋转90,将该图吧噢存到硬盘上
i=imread(’C:\Documents and Settings\Administrator\桌面\dddd。bmp’);
a=double(i);
pr=a(:,:,1);
pg=a(:,:,2);
pb=a(:,:,3);
a1=(pr+pg+pb)/3;
x=size(a1);
t=zeros(x(2),x(1));
for i=1:x(1)
    t(:,x(1)-i+1)=a1(i,:)’;
end
figure;imshow(uint8(t));
imwrite(uint8(t),'C:\Documents and Settings\Administrator\桌面\dddd2。bmp’);
4。读取一幅图像,并显示图像,在图像上用鼠标取两个点,并在图上用*号显示这两个点,以这两个点为左上角和右下角在图上画一个矩形框,截取该矩形框内的子图像,显示并保存在硬盘上
i=imread(’\\psf\Home\Desktop\ddd2.bmp’);
figure;
imshow(i);
hold on;
[x,y]=ginput(2);
for m=1:2
plot(x(m),y(m),’*’);
end
n=imcrop(i,[min(x(1),x(2)),min(y(1),y(2)),abs(x(1)—x(2)),abs(y(1)-y(2))]);
figure;
imshow(n);
imwrite(n,'\\psf\Home\Desktop\ddd3。bmp’);
第二次试验
1.鼠标点击空白图面,实时显示鼠标点和轨迹
function dsa
figure('WindowButtonDownFcn’,@md);
axes(’XLimMode’,’manual',’yLimMode',’manual');
hold on;
function md(src,eventdata)
ud=get(src,'userdata’);
cp=get(gca,’currentpoint’);
x=cp(1,1);y=cp(1,2);
plot(x,y,’r*’);
if ~isempty(ud)
    line([ud(1),x],[ud(2),y]);
end
set(src,'userdata’,[x,y]);
2.音乐柱状图的动态标识
for i=1:1000
    pause(0。3);
    y=rand(1,10);
    bar(y);
end
3。编写一个函数,以图像文件路径为输入参数
(1)显示灰度图像
(2)图像灰度值通过y=x2变换并拉伸到【0,255】;
(3)图像分为上下左右四个字块,并显示这四个子块图像;
(4)把左上子块和右下子块图像进行交换,把右上和左下进行交换,并显示交换后的图像
w=imread('C:\Documents and Settings\Administrator\桌面\图片.bmp');
figure(1); 
b=rgb2gray(w); 
figure(1);
imshow(uint8(b));title(’灰度图'); 
c=b。*b; 
figure(2);
imshow(uint8(c));title('改变灰度图');
[hang lie]=size(b);
figure(3);
title('分割灰度图’);
subplot(2,2,1);
imshow(uint8(b(1:hang/2,1:lie/2)));
subplot(2,2,2);
imshow(uint8(b(1:hang/2,lie/2:lie)));
subplot(2,2,3);
imshow(uint8(b(hang/2:hang,1:lie/2)));
subplot(2,2,4);
imshow(uint8(b(hang/2:hang,lie/2:lie)));
figure(4); 
title('交换分割灰度图’); 
subplot(2,2,4); 
imshow(uint8(b(1:hang/2,1:lie/2))); 
subplot(2,2,3);
imshow(uint8(b(1:hang/2,lie/2:lie)));
subplot(2,2,2); 
imshow(uint8(b(hang/2:hang,1:lie/2)));
subplot(2,2,1);
imshow(uint8(b(hang/2:hang,lie/2:lie)));
第三次试验
制作一个GUI,实现简易计算器
第四次试验
1。求方程2x5+6x4+11x3+5x2+9x+12=0的跟
y=[2,6,11,5,9,12];
x=roots(y);
disp(x);
2。设方程的跟为x=【—5,3,8,9】,求对应的x多项式系数
x=[-5 ,3 ,8 ,9];
y=poly(x);
disp(y);
3。编写子函数可对任意两个多项式进行加减操作(自动补零)   
unction y=jiafa(x1,x2)
n1=length(x1);
n2=length(x2);
if n1〉n2
    x2=[zeros(1,n1—n2),x2];
elseif n1〈n2
    x1=[zeros(1,n2-n1),x1];
end
y=x1+x2;
function y=jianfa(x1,x2)
n1=length(x1);
n2=length(x2);
if n1〉n2
    x2=[zeros(1,n1-n2),x2];
elseif n1<n2
    x1=[zeros(1,n2-n1),x1];
end
y=x1-x2;
4.实现一副灰度图像的2倍放大,并在硬盘上保存该放大图像
w=imread(’C:\Users\Administrator\Desktop\未命名.bmp’);
b=rgb2gray(w);
figure(1);
imshow(uint8(b));
title('灰度图’);
b=double(b);
[hang lie]=size(b);
width=1:lie;
depth=1:hang;
wi=1:(lie—1)/(2*lie-1):lie;
di=1:(hang—1)/(2*hang-1):hang;
c=interp2(width,depth',b,wi,di','cubic’);
figure(2);
imshow(uint8(c));
title(’放大图’);
imwrite(c,’D:\图片\未命名放大图.bmp',’bmp’);
第五次试验
已知描述某连续系统的微分方程为2y’’(t)+y’(t)+8y(t)=f(t)
1。用留数法求解脉冲响应阶跃响应,并画出响应的被波形
a=[2,1,8];
b=[1];
t=0:0。01:30;
[r,p]=residue(b,a);
y=0;
len=length(r);
for i=1:len;
    y=y+r(i)*exp(p(i)*t);
end
subplot(2,1,1);
plot(t,y);
title('脉冲响应');
a=[2,1,8,0];
[r,p]=residue(b,a);
y=0;
len=length(r);
for i=1:len;
    y=y+r(i)*exp(p(i)*t);
end
subplot(2,1,2);
plot(t,y);
title(’脉冲响应');
2.绘出该系统在0—30秒范围内,并以时间间隔0.01秒取样的冲击响应和阶跃响应的时域波形,以及频率响应波形
a=[2,1,8];
b=[1];
t=0:0.01:30;
figure(1);
subplot(2,1,1);
impulse(b,a,t);
title('脉冲响应’);
subplot(2,1,2);
step(b,a,t);
title('阶跃响应');
w=0:0.1:2*pi*5;
figure(2);
freqs(b,a,w);
title('频率响应’);
3.求出系统在0—30秒范围内,并以时间间隔0.01秒取样的冲激响应和阶跃响应的数值解,以及频率响应数值解,并用数值解画出波形
a=[2,1,8];
b=[1];
t=0:0。01:30;
y1=impulse(b,a,t);
figure(1);
subplot(2,1,1);
plot(t,y1);
title(’脉冲响应’);
y2=step(b,a,t);
subplot(2,1,2);
plot(t,y2);
title(’阶跃响应');
w=0:0。1:2*pi*5;