文档介绍:数据可视化(即画图)部分作业
x = a cost …e
、短轴a=4,b=2,用“小红点线”画椭圆丿 。(参见图P5-1)
y = bsi nt
程序:
t=2*pi*(0:199)/199;
a=4;b=2;
x=a*cos(t);y=b*sin(t);
plot(x,y,'r.','MarkerSize',15)
axis equal
-2 -1 0 12 3 4
图 p5-1
'=1-C0S^绘制如图p5-2的心脏线。(提示:采用极坐标绘线指令 polar) clf
t = 0:.01:2*pi;
P=1-cos(t); pline=polar(t,P,'r'), set(pline,'LineWidth',5)
title('P=1-cos\theta')
图 p5-2
3. A,B,C三个城市上半年每个月的国民生产总值见表 。试画出如图p5-3所示的三城市
上半年每月生产总值的累计直方图。(提示:使用指令 bar)
(单位:亿元)
城市
1月
2月
3月
4月
5月
6月
A
170
120
180
200
190
220
B
120
100
110
180
170
180
C
70
50
80
100
95
120
clear
x=1:6;
Y=[170 120
180
200
190
220;
120
100
110
180
170
180;
70
50
80
100
95
120]
bar(x,Y','grouped');
bar(x,丫 ','stacked');
colormap(cool);
% lege nd('A','B',C,'Locatio n',‘Northwest')
lege nd('A','B',C,2)
图 p5-3
(即令--1 )冲激响应可表示为
y(t)二
齐亠 sin( P t)
te」
丄J」_edm]
2 :
0 _ :: 1
=1 ,其中1 f『|1 -,2 |, 为阻尼
1
系数。试在同一张图上,画出 = : : ,时间区间为
r [0,18]。此外,要求(1) 「:1的各条曲线用蓝色, 1的用红色,二-1的用黑
色,且线较粗;(2) = =。(本题
要求图形参见图p5-4)
%
clc,clf,clear;
t=(0::18)';
N=length(t);
zeta=::;
L=length(zeta); y=zeros(N,L); hold on for k=1:L zk=zeta(k); beta=sqrt(abs(1-zkA2)); if zk-1<-2*eps
y=1/beta*exp(-zk*t).*sin(beta*t); plot(t,y,'b') if
text(,,'\zeta = ')