fft fast transform fourier problem ?

5 ビュー (過去 30 日間)
benzouine yassine
benzouine yassine 2015 年 4 月 7 日
回答済み: benzouine yassine 2015 年 4 月 8 日
Hi,
I am having trouble plotting the fft (fast fourier transform) of this signal :
% Create square wave for ii = 1 : length(x) if x(ii) < 0 y(ii) = 0; elseif x(ii) > 1 y(ii) = 0; else y(ii) = 1; end end
% Plot square wave subplot(1,1,1) plot(x,y) grid;
i wanna this fft .

回答 (2 件)

buzz
buzz 2015 年 4 月 7 日
What's exactly the matter? You have a rect impulse, use the fft function implemented in matlab:
Y = fft(y);
You should have a sinc function into fourier domain. Remember the fft is normalized to the length of the signal to be transformed. So, in order to view the amplitude correctly:
A = abs(Y)/length(y);
About the frequency axis (normalized frequency):
N = length(y);
df = 1/N;
f_axis = 0:df:1-df
plot(f_axis,y);
That's all. Waiting for more detail about the question.

benzouine yassine
benzouine yassine 2015 年 4 月 8 日
Thks for your answer,but when i use the fft i don't get a sinc of my signal , why ? this is my final code :
clc, clear
Fs = 1000; % Sampling Frequency x = -5 : 1/Fs : 5; % Time vector % Create square wave for ii = 1 : length(x) if x(ii) < 0 y(ii) = 0; elseif x(ii) > 1 y(ii) = 0; else y(ii) = 1; end end
% Plot square wave %subplot(3,2,1) plot(x,y) grid; axis([-5 5 -2 2])
figure;
Y = fft(y);
A = abs(Y)/length(y);
N = length(y); df = 1/N; f_axis = 0:df:1-df plot(f_axis,y); grid;
figure1;

カテゴリ

Help Center および File ExchangeDiscrete Fourier and Cosine Transforms についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by