资源描述
实验时间: 2011.12.22
实验地点:计算机网络中心5号机房
一、实验名称:数据和函数的可视化(1)
二、实验目的:
1.掌握离散函数和连续函数的可视化。
2.熟练掌握二维曲线和图形。
三、实验内容:
1.用图形表示离散函数。
x=(-15:15)';
y=abs(x);
plot(x,y,'rp','MarkerSize',15)
axis equal
grid on
xlabel('x'),ylabel('y')
2.用图形表示连续调制波形y=cos(t)sin(5t)。
t1=(0:11)/11*pi;
t2=(0:400)/400*pi;
t3=(0:50)/50*pi;
y1=cos(t1).*sin(5*t1);
y2=cos(t2).*sin(5*t2);
y3=cos(t3).*sin(5*t3);
subplot(2,2,1),plot(t1,y1,'r.')
axis([0,pi,-1,1]),title('(1) 点过少的离散图形 ')
subplot(2,2,2),plot(t1,y1,t1,y1,'r.')
axis([0,pi,-1,1]),title('(2)点过少的连续图形 ')
subplot(2,2,3),plot(t2,y2,'g.')
axis([0,pi,-1,1]),title('(3) 点密集的离散图形')
subplot(2,2,4),plot(t3,y3,'m')
axis([0,pi,-1,1]),title('(4)点足够的连续图形')
3.用图形表示y=cos(t)sin5(t)。
t=(0:pi/200:pi)';
y1=cos(t)*[2,-2];
y2=cos(t).*sin(5*t);
t3=pi*(0:13)/13;
y3=cos(t3).*sin(5*t3);
plot(t,y1,'g:',t,y2,'-bo')
hold on
plot(t3,y3,'s','Markersize',15,'MarkerEdgeColor',[0,1,0],'MarkerFaceColor',[1,0.5,0])
axis([0,pi,-1,1])
hold off
4. 多次叠绘
t=2*pi*(0:50)/50;
y=sin(t).*exp(-0.9*t);
stem(t,y,':g','Color','b');
hold on
stairs(t,y,':r','Linewidth',3.5)
hold off
legend('\fontsize{20}\it stem','\fontsize{20}\it stairs')
box on
5.多子图和获取二维图形数据
t=(2*pi*(1:10000)/10000)';
y1=cos(t);y2=sin(5*t);y3=cos(t).*sin(5*t);
subplot(2,2,1),plot(t,y1,'m','LineWidth',2);axis([0,pi,-1,1])
subplot(2,2,2),plot(t,y2,'g','LineWidth',4);axis([0,pi,-1,1])
subplot('position',[0.2,0.1,0.6,0.4])
plot(t,y3,'b-',t,[y1,-y1],'r','LineWidth',3)
axis([0,pi,-1,1])
[t,y3]=ginput(4)
t =
0.3039
0.9116
1.4259
1.7531
y3 =
0.9235
-0.6176
0.1118
-0.1118
四、实验总结:
通过本次实验,我学会了离散函数和连续函数的可视化,可以将具体的函数以图形的形式表现出来,对函数的认识更加的形象;而且也了解的函数自变量取值数量的多少直接影响函数图形的形状。函数的取值点太少则会造成函数图形不精确,太多则会造成图形过于密集,所以应该经过反复试验,取合适的函数自变量点。我还学会了二维曲线和图形的画法,并且了解到一张图上可以画出多幅子图,将函数图像进行对比,还可以对函数图形进行线型、颜色、线宽等的修饰。
第 6 页
展开阅读全文