浙江大学远程教育学院
《可视化计算》课程作业2015年(冬)
姓名: 年级:
袁磊 15秋计算机
学 号: 学习中心:
715003012008 宁波
————————————————————————————— 注意:所有图像的标题必须呈现足够你本人信息
1.(10分)求解下列线性方程组的解: u?1.5v?2x?9y?7z?33.6v?0.5x?4y?4z??47u?10v?3x?22y?33z?20 3u?7v?8.5x?21y?6z?53u?8v?90y?20z?16
2.(10分)信号y = 5*sin(pi*20*t)+3*cos(2*pi*50*t)幅度为1的白噪声的干扰,请画出此信号,然后进行傅立叶变换,画出变换后的频域信号。
clear
t=0:0.001:0.6;
y=5*sin(pi*20*t)+3*cos(2*pi*50*t); y=y+randn(1,length(t)); subplot(2,2,1); plot(y(1:100));
title('袁磊的傅立叶变换频域信号输出图象') xlabel('变换前的信号');
Y=fft(y,256); subplot(2,2,2); Y=real(Y); plot(Y(1:256)); xlabel('变换后频域信号') Pyy=Y.*conj(Y)/256; f=1000*(0:255)/256; subplot(2,2,3); plot(Pyy(1:256));
xlabel('信号功率密度');
3.(10分)在空间有一个带正电的点电荷,请画出此点电荷的空间电位分布与电场强度的空间分布图。
fprintf('请输入电位分布方程 V(x, y)\\n');
>>请输入电位分布方程 V(x, y) V= input(':', 's');
:log(x.^2 + y.^2) NGrid = 20; xMax = 5; yMax = 5;
xPlot = linspace(-xMax, xMax, NGrid); [x, y] = meshgrid(xPlot); VPlot = eval(V);
[ExPlot, EyPlot] = gradient(-VPlot); clf;
subplot(1, 2, 1), meshc(VPlot); set(gcf, 'color', 'w') xlabel('x'); ylabel('y'); zlabel('电位');
subplot(1, 2, 2), axis([-xMax xMax -yMax yMax]); cs =contour(x, y, VPlot); clabel(cs); hold on;
quiver(x, y,ExPlot, EyPlot); xlabel('x'); ylabel('y'); hold off;
title('电位分布与电位强度线图 袁磊制作')
4.(10分)仿照课本第11章的太阳|地球|月亮|卫星,绕转动画实例,呈现地球绕太阳运转的动画。
程序源码:
clear; clc; close all;
x0 = 0; y0 =0; r0=80; Lmin0 = 0; Lmax0 = 0; T0= 2160; w0 = 0*pi/T0; q0 = 0; x1 = 0; y1 = 0; r1 = 40; Lmin1 = 25; Lmax1 = 30; T1= 1080; w1 = pi/T1; q1 = 0;
hh = figure('numbertitle', 'off','name', '地球绕着太阳转的演示动画'); sun = line(0, 0, 'color', 'r', 'linestyle', '.', 'erasemode', 'xor', 'markersize', r0); earth = line(x0, y0, 'color', 'k', 'linestyle', '.', 'erasemode', 'xor', 'markersize', r1); axis off
title('地球绕着太阳转 袁磊绘', 'fontname','宋体', 'fontsize', 9, 'FontWeight', 'demi', 'Color', 'black');
text(-50, 50,'太阳');
line(-55, 50, 'color', 'r', 'marker', '.', 'markersize', 80); text(-50, 40, '地球');
line(-55, 40, 'color', 'k', 'marker', '.', 'markersize', 40);
s1 = [0:.01:2*pi];
line(Lmax1*cos(s1), Lmin1*sin(s1), 'linestyle', ':'); axis([-60, 60, -60, 60]); t=0; while 1
if ~ishandle(hh) return; end
q0 = t*w0; q1 = t*w1; t = t+1;
if t>= 4320; t = 0; end
x0 = Lmax0 *cos(q1); y1 = Lmin0*sin(q1);
x1 = x0 + Lmax1*cos(q1); y1 = y0 + Lmin1 * sin(q1); set(sun, 'xdata', x0, 'ydata', y0); set(earth, 'xdata', x1', 'ydata', y1);
drawnow; end