在MATLAB中绘制三角形信号并求其傅里叶变换
我有以下用于矩形脉冲的代码:在MATLAB中绘制三角形信号并求其傅里叶变换,matlab,fft,Matlab,Fft,我有以下用于矩形脉冲的代码: clear all dt=.001; t=[-25:dt:25]; x=(5/2)*(sign(t+10)-sign(t-10)); %subplot(2,2,1); plot(t,x); title('Rectangular pulse with width 10ms'); xlabel('time(ms)'); ylabel('Amplitude(V)'); axis([-25 25 0 6]); >> y=fftshift(fft(x)); %
clear all
dt=.001;
t=[-25:dt:25];
x=(5/2)*(sign(t+10)-sign(t-10));
%subplot(2,2,1);
plot(t,x);
title('Rectangular pulse with width 10ms');
xlabel('time(ms)');
ylabel('Amplitude(V)');
axis([-25 25 0 6]);
>> y=fftshift(fft(x)); % moving the zero-frequency component to the center of the array
N=length(y); %to take the frquecny axis of the hoarmonics.
n=-(N-1)/2:(N-1)/2; %divide the frequency compone
f=sqrt(y.*conj(y)); % to take the amplitude of each hoarmony.
title('Rectangular pulse amplitude');
xlabel('frequency component(harmoney)');
ylabel('Amplitude of the harmoney');
plot(n,f);
axis([-50 50 0 150000]);
>>
>> y=fftshift(fft(x)); % moving the zero-frequency component to the center of the array
N=length(y); %to take the frquecny axis of the hoarmonics.
n=-(N-1)/2:(N-1)/2; %divide the frequency compone
f=sqrt(y.*conj(y)); % to take the amplitude of each hoarmony.
title('Rectangular pulse amplitude');
xlabel('frequency component(harmoney)');
ylabel('Amplitude of the harmoney');
plot(n,f);
axis([-50 50 0 150000]);
如何获得三角形脉冲
此外,上面的代码没有找到矩形信号的傅里叶变换。如何找到它?如何找到三角形信号?是否可以在MATLAB中计算或手动评估 时间信号的长度应足够长,以便在频域上获得适当的分辨率 请试着像这样改变你的时间段
t=[-100:dt:100];
x=0.5*max(10-abs(t),0);
就三角信号而言,我认为brainkz的评论是最好的
在你的情况下,请像这样改变你的时间信号
t=[-100:dt:100];
x=0.5*max(10-abs(t),0);
变化
x=(5/2)*(符号(t+10)-符号(t-10))代码>至x=max(5-abs(t),0)代码>你可以手动完成FT,你可以在谷歌上搜索一些关于这个的课堂讲稿。MATLAB也可以做到这一点: