找回密码
 注册
Simdroid-非首页
楼主: 颜扎牧之

Computer Exploration in Signals and System using MATALB中的练习

[复制链接]
 楼主| 发表于 2014-8-19 14:57:51 | 显示全部楼层 来自 北京
% Exercise1_6_b
% 在MATLA R2012a版本中symmul似乎不可用

x=sym('cos(2*pi*t/T)*sin(2*pi*t/T)');
x1=subs(x,'T',4);
subplot(3,1,1),ezplot(x1,[0,32])
x2=subs(x,'T',8);
subplot(3,1,2),ezplot(x2,[0,32])
x3=subs(x,'T',16);
subplot(3,1,3),ezplot(x3,[0,32])

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

×
回复 不支持

使用道具 举报

 楼主| 发表于 2014-8-21 16:50:08 | 显示全部楼层 来自 北京
Simdroid开发平台
% Exercise1_6_c
syms t a
x=exp(-a*t)*cos(2*pi*t);
x1=subs(x,'a',1/2);
figure
hold on
ezplot('0.1',[0,15])
ezplot('-0.1',[0,15])
ezplot(x1,[0,15]),ylim([-1.5,1.5])
grid on
hold off
% 由所画图可以知道,|x(t)|最后一次跨过0.1是在4.5和5之间,在最后一次跨过前,总共有4个完整周期
td1=evalin(symengine,'numeric::solve(exp(-0.5*t)*cos(2*pi*t)=-0.1,t=4.5..5)')
x2=subs(x,'a',0.25);
figure
hold on
ezplot('0.1',[0,20])
ezplot('-0.1',[0,20])
ezplot(x2,[0,20]),ylim([-1.5,1.5])
grid on
hold off
% 由所画图可以知道,|x(t)|最后一次跨过0.1是在9和9.5之间,在最后一次跨过前,总共有,9个完整周期
td2=evalin(symengine,'numeric::solve(exp(-0.25*t)*cos(2*pi*t)=0.1,t=9..9.5)')
x3=subs(x,'a',0.125);
figure
hold on
ezplot('0.1',[0,25])
ezplot('-0.1',[0,25])
ezplot(x3,[0,25]),ylim([-1.5,1.5])
grid on
hold off
% 由所画图可以知道,|x(t)|最后一次跨过0.1是在18和18.5之间,在最后一次跨过前,总共有18个完整周期
td2=evalin(symengine,'numeric::solve(exp(-0.125*t)*cos(2*pi*t)=0.1,t=18..18.5)')

% 品质因数Q=(2*pi/T)/(2*a),所以当a取1/2,1/4,1/8时候品质因数比值为1:2:4,而周期是4,9,18,所以不正比。
回复 不支持

使用道具 举报

 楼主| 发表于 2014-8-26 08:33:12 | 显示全部楼层 来自 北京
% Exercise1_6_d
syms t;
x_real=real(exp(i*2*pi*t/16)+exp(i*2*pi*t/8));
x_imag=imag(exp(i*2*pi*t/16)+exp(i*2*pi*t/8));
hold on
line_real=ezplot(x_real);
set(line_real,'Color','r','LineWidth',3)
line_imag=ezplot(x_imag);
set(line_imag,'Color','g','LineWidth',3)
legend('RealPart','ImagePart')
title(' ')
grid on
hold off
回复 不支持

使用道具 举报

 楼主| 发表于 2014-8-26 08:36:59 | 显示全部楼层 来自 北京
% Exercise1_6_e
syms t;
x=exp(i*2*pi*t/16)+exp(i*2*pi*t/8);
xr=sreal(x);
xi=simag(x);
hold on
line_real=ezplot(xr,[0,32]);
set(line_real,'Color','r','LineWidth',3)
line_imag=ezplot(xi,[0,32]);
set(line_imag,'Color','g','LineWidth',3)
legend('RealPart','ImagePart')
title(' ')
grid on
hold off

%基波周期是16
回复 不支持

使用道具 举报

 楼主| 发表于 2014-8-26 08:59:20 | 显示全部楼层 来自 北京
颜扎牧之 发表于 2014-8-26 08:36
% Exercise1_6_e
syms t;
x=exp(i*2*pi*t/16)+exp(i*2*pi*t/8);

function xr=sreal(x)
xr=real(x);
回复 不支持

使用道具 举报

 楼主| 发表于 2014-8-26 09:00:07 | 显示全部楼层 来自 北京
颜扎牧之 发表于 2014-8-26 08:36
% Exercise1_6_e
syms t;
x=exp(i*2*pi*t/16)+exp(i*2*pi*t/8);

function xi=simag(x)
xi=imag(x);
回复 不支持

使用道具 举报

 楼主| 发表于 2014-8-26 09:01:15 | 显示全部楼层 来自 北京
% Exercise1_6_f
syms t;
x=exp(i*2*pi*t/16)+exp(i*2*pi*t/8);
xm=sabs(x);
xa=sangle(x);
hold on
line_real=ezplot(xm,[0,32]),ylim([-2,2])
set(line_real,'Color','r','LineWidth',3)
line_imag=ezplot(xa,[0,32]),ylim([-2,2])
set(line_imag,'Color','g','LineWidth',3)
legend('RealPart','ImagePart')
title(' ')
grid on
hold off

% 周期函数,所以相位也周期性的变化。
回复 不支持

使用道具 举报

 楼主| 发表于 2014-8-26 09:02:11 | 显示全部楼层 来自 北京
颜扎牧之 发表于 2014-8-26 09:01
% Exercise1_6_f
syms t;
x=exp(i*2*pi*t/16)+exp(i*2*pi*t/8);

function xm=sabs(x)
xr=real(x);
xi=imag(x);
xm=sqrt(xr^2+xi^2);
回复 不支持

使用道具 举报

 楼主| 发表于 2014-8-26 09:03:25 | 显示全部楼层 来自 北京
颜扎牧之 发表于 2014-8-26 09:01
% Exercise1_6_f
syms t;
x=exp(i*2*pi*t/16)+exp(i*2*pi*t/8);

function xa=sangle(x)
xr=real(x);
xi=imag(x);
xa=atan(xi/xr);
回复 不支持

使用道具 举报

 楼主| 发表于 2014-8-26 11:40:40 | 显示全部楼层 来自 北京
% Exercise1_7_a

syms t;
f=t*(heaviside(t)-heaviside(t-2));
ezplot(f,[-3,3]);

% 可能是MTALAB版本问题,刚开始我在搜索文件夹下创建了一个Heaviside的函数,但是每次画
% f=t*(heaviside(t)-heaviside(t-2))时都不是想要的图形,后来干脆删掉Heaviside函数,用
% 默认的heaviside函数可以画出想要的图形。

% 另外,在这里看到了MuPAD和MATLAB是两个系统,刚开始我设定syms t positive,画出的图形不对,用clear t清除后再创建画出的图一样不对,用syms t clear后才能画出正确的图形。
回复 不支持

使用道具 举报

 楼主| 发表于 2014-8-26 12:40:53 | 显示全部楼层 来自 北京
% Exercise1_7_b_c

% 翻转
% 超前1
% 延时3
% 超前1后翻转
% 超前1,压缩2,翻转

syms t;
f=t*(heaviside(t)-heaviside(t-2));
ezplot(f,[-3,3]);
g1=subs(f,'t','-t');
figure
ezplot(g1,[-3,3])
g2=subs(f,'t','t+1')
figure
ezplot(g2,[-3,3])
g3=subs(f,'t','t-3')
figure
ezplot(g3,[-1,6])
g4=subs(f,'t','-t+1')
figure
ezplot(g4,[-1,6])
g5=subs(f,'t','-2*t+1')
figure
ezplot(g5,[-2,2])
回复 不支持

使用道具 举报

 楼主| 发表于 2014-8-26 16:27:46 | 显示全部楼层 来自 北京
% Exercise1_8_a
syms t;
x1=cos(t*pi/5);
x2=sin(t*pi/5);
x3=exp(2*i*pi*t/3)+exp(i*pi*t);

% Exercise1_8_b

ezplot(x1,[-10,10])
grid on
figure
ezplot(x2,[-10,10])
grid on
x3_r=real(x3);
x3_i=imag(x3);
figure
hold on
ezplot(x3_r,[-6,6])
ezplot(x3_i,[-6,6])
grid on
hold off

% Exercise1_8_c
syms a;
x3_conj=subs(x3,'i','-i');
E1=int(x1*x1,t,-a,a);
E2=int(x2*x2,t,-a,a);
E3=int(x3*x3_conj,t,-a,a);

% Exercise1_8_d
figure
ezplot(E1,[0,30])
grid on
figure
ezplot(E2,[0,30])
grid on
figure
ezplot(E3,[0,30])
grid on
E1_T=subs(E1,a,5);
E2_T=subs(E2,a,5);
E3_T=subs(E3,a,3);

% Exercise1_8_e
P1=E1/(2*a);
P2=E2/(2*a);
P3=E3/(2*a);
figure
ezplot(P1,[0.1,60])
grid on
figure
ezplot(P2,[0.1,60])
grid on
figure
ezplot(P3,[0.1,60])

P1_NUM=subs(P1,'a',5)
P2_NUM=subs(P2,'a',5)
P3_NUM=subs(P3,'a',3)
% 有图形可以看出,三个P都随a值的增大而减小
% 估计P1,P2无穷的值为0.5,P3无穷的值为0
% 相比较而言,除了P3无穷与P3/T值比较为0/-1.5694e-33外,P1和P2的相等。
% 由数学计算可以预先得出其P无穷大的值

% Exercise1_8_f

% x1(t)和x2(t)的Pa收敛到同一个值,因为他们两个具有相同的周期和相同的幅值。

P=simple(x1+x2)
回复 不支持

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|小黑屋|联系我们|仿真互动网 ( 京ICP备15048925号-7 )

GMT+8, 2024-7-3 07:20 , Processed in 0.032975 second(s), 8 queries , Gzip On, MemCache On.

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表