
本人是刚学matlab的菜鸟,请各位大神帮帮忙
clearallclosealln=0:80fs1=20fs2=50fs3=80T1=1/fs1T2=1/fs2T3=1/fs3t=0:0.01:2*piA=input(...
clear all
close all
n=0:80
fs1=20
fs2=50
fs3=80
T1=1/fs1
T2=1/fs2
T3=1/fs3
t=0:0.01:2*pi
A=input('振幅的值A=20:')
a=input('衰减因子a=20:')
w0=input('角频率的值w0=20:')
y0=A*exp(-a*t).*sin(w0*t)
y1=A*exp(-a*n*T1).*sin(w0*n*T1)
y2=A*exp(-a*n*T2).*sin(w0*n*T2)
y3=A*exp(-a*n*T3).*sin(w0*n*T3)
close all
figure(1)
subplot(2,1,1)
plot(t,y0)
grid on
title('原始连续时间信号')
subplot(2,1,2)
stem(t,y0)
grid on
title('原始离散时间信号')
figure(2)
subplot(2,1,1)
plot(n,y1)
grid on
title('经20Hz采样后的连续时间信号')
subplot(2,1,2)
stem(t,y1)
grid on
title('经20Hz采样后的离散时间信号')
figure(3)
subplot(2,1,1)
plot(n,y2)
grid on
title('经20Hz采样后的连续时间信号')
subplot(2,1,2)
stem(t,y2)
grid on
title('经50Hz采样后的离散时间信号')
figure(4)
subplot(2,1,1)
plot(n,y3)
grid on
title('经80Hz采样后的连续时间信号')
subplot(2,1,2)
stem(t,y3)
grid on
title('经80Hz采样后的离散时间信号')
figure(5)
w=-40:40
Y1=fft(y1)
subplot(2,1,1)
plot(w,abs(Y1)
grid
ylabel('幅度')
title('经20Hz采样后的连续时间信号的幅度谱')
subplot(2,1,2)
plot(w,angle(Y1))
grid
ylabel('幅角')
title('经20Hz采样后的离散时间信号的相位谱')
figure(6)
w=-40:40
Y1=fft(y2)
subplot(2,1,1)
plot(w,abs(Y2))
grid
ylabel('幅度')
title('经50Hz采样后的连续时间信号的幅度谱')
subplot(2,1,2)
plot(w,angle(Y2))
grid
ylabel('幅角')
title('经50Hz采样后的连续时间信号的相位谱')
figure(7)
w=-40:40
Y1=fft(y3)
subplot(2,1,1)
plot(w,abs(Y3))
grid
ylabel('幅度')
title('经80Hz采样后的连续时间信号的幅度谱')
subplot(2,1,2)
plot(w,angle(Y3))
grid
ylabel('幅角')
title('经80Hz采样后的连续时间信号的相位谱')
figure(8);
y1=ifft(Y1);
magy1=real(y1);
ti=[0:length(y1)-1]/fs1;
subplot(3,1,1);
plot(ti,magy1);
xlabel(‘n');
ylabel(‘y1');
title('通过IFFT转换的20Hz采样信号波形');
grid;
y2=ifft(Y2);
magy2=real(y2);
ti=[0:length(y2)-1]/fs2;
subplot(3,1,2);
plot(ti,magy2);
xlabel(‘n');
ylabel(‘y2');
title('通过IFFT转换的50Hz采样信号波形');
grid;
y3=ifft(Y3);
magy1=real(y3);
ti=[0:length(y3)-1]/fs3;
subplot(3,1,3);
plot(ti,magy3);
xlabel(‘n');
ylabel(‘y3');
title('通过IFFT转换的80Hz采样信号波形');
gridi=[0:length(y3)-1]/fs3;
subplot(3,1,3);
plot(ti,magy3);
xlabel(‘n');
ylabel(‘y3');
title('通过IFFT转换的80Hz采样信号波形');
grid
??? y0=A*exp(-a*t).*sin(w0*t)
|
Error: Missing variable or function. 展开
close all
n=0:80
fs1=20
fs2=50
fs3=80
T1=1/fs1
T2=1/fs2
T3=1/fs3
t=0:0.01:2*pi
A=input('振幅的值A=20:')
a=input('衰减因子a=20:')
w0=input('角频率的值w0=20:')
y0=A*exp(-a*t).*sin(w0*t)
y1=A*exp(-a*n*T1).*sin(w0*n*T1)
y2=A*exp(-a*n*T2).*sin(w0*n*T2)
y3=A*exp(-a*n*T3).*sin(w0*n*T3)
close all
figure(1)
subplot(2,1,1)
plot(t,y0)
grid on
title('原始连续时间信号')
subplot(2,1,2)
stem(t,y0)
grid on
title('原始离散时间信号')
figure(2)
subplot(2,1,1)
plot(n,y1)
grid on
title('经20Hz采样后的连续时间信号')
subplot(2,1,2)
stem(t,y1)
grid on
title('经20Hz采样后的离散时间信号')
figure(3)
subplot(2,1,1)
plot(n,y2)
grid on
title('经20Hz采样后的连续时间信号')
subplot(2,1,2)
stem(t,y2)
grid on
title('经50Hz采样后的离散时间信号')
figure(4)
subplot(2,1,1)
plot(n,y3)
grid on
title('经80Hz采样后的连续时间信号')
subplot(2,1,2)
stem(t,y3)
grid on
title('经80Hz采样后的离散时间信号')
figure(5)
w=-40:40
Y1=fft(y1)
subplot(2,1,1)
plot(w,abs(Y1)
grid
ylabel('幅度')
title('经20Hz采样后的连续时间信号的幅度谱')
subplot(2,1,2)
plot(w,angle(Y1))
grid
ylabel('幅角')
title('经20Hz采样后的离散时间信号的相位谱')
figure(6)
w=-40:40
Y1=fft(y2)
subplot(2,1,1)
plot(w,abs(Y2))
grid
ylabel('幅度')
title('经50Hz采样后的连续时间信号的幅度谱')
subplot(2,1,2)
plot(w,angle(Y2))
grid
ylabel('幅角')
title('经50Hz采样后的连续时间信号的相位谱')
figure(7)
w=-40:40
Y1=fft(y3)
subplot(2,1,1)
plot(w,abs(Y3))
grid
ylabel('幅度')
title('经80Hz采样后的连续时间信号的幅度谱')
subplot(2,1,2)
plot(w,angle(Y3))
grid
ylabel('幅角')
title('经80Hz采样后的连续时间信号的相位谱')
figure(8);
y1=ifft(Y1);
magy1=real(y1);
ti=[0:length(y1)-1]/fs1;
subplot(3,1,1);
plot(ti,magy1);
xlabel(‘n');
ylabel(‘y1');
title('通过IFFT转换的20Hz采样信号波形');
grid;
y2=ifft(Y2);
magy2=real(y2);
ti=[0:length(y2)-1]/fs2;
subplot(3,1,2);
plot(ti,magy2);
xlabel(‘n');
ylabel(‘y2');
title('通过IFFT转换的50Hz采样信号波形');
grid;
y3=ifft(Y3);
magy1=real(y3);
ti=[0:length(y3)-1]/fs3;
subplot(3,1,3);
plot(ti,magy3);
xlabel(‘n');
ylabel(‘y3');
title('通过IFFT转换的80Hz采样信号波形');
gridi=[0:length(y3)-1]/fs3;
subplot(3,1,3);
plot(ti,magy3);
xlabel(‘n');
ylabel(‘y3');
title('通过IFFT转换的80Hz采样信号波形');
grid
??? y0=A*exp(-a*t).*sin(w0*t)
|
Error: Missing variable or function. 展开
1个回答
展开全部
那个 我复制了你的文档试了下 发现你输入的括号 (是中文的括号 matlab只识别英文的( 这个地方错了
仔细检查了下 你下面的输入法错误很多 基本都是 : ‘ ;()都是中文的,建议用matlab的find&replace 就是在编辑m文件下按ctrl+f出来的 把所有中文的符号全部改为英文的
再来就是你67行少了个括号 就是figure(5)那一段里面的第一个plot
最后一个就是stem函数 要求X,Y向量维数一致,但是t和y1不是相同维数的,其实我不是学你这个专业的,不是很了解stem是做什么的,所以这里帮不了你了
仔细检查了下 你下面的输入法错误很多 基本都是 : ‘ ;()都是中文的,建议用matlab的find&replace 就是在编辑m文件下按ctrl+f出来的 把所有中文的符号全部改为英文的
再来就是你67行少了个括号 就是figure(5)那一段里面的第一个plot
最后一个就是stem函数 要求X,Y向量维数一致,但是t和y1不是相同维数的,其实我不是学你这个专业的,不是很了解stem是做什么的,所以这里帮不了你了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询