Getting an FFT signal into a for loop.
Afficher commentaires plus anciens
%% Q1
clc;
clear;
n=0:1000;
fs=8000; % Sampling frequency, Hz
nfft=1024; % Number of samples
nf=fs*(-nfft/2:nfft/2-1)./nfft; % establishing frequency points (x-axis), figure 2
time=(1:length(n))./fs; % establishing time points (x-axis), figure 1
x1=5*cos(2*pi*500*time);
x2=5*cos(2*pi*1200*time+0.25*pi);
x3=5*cos(2*pi*1800*time+0.5*pi);
x=x1+x2+x3; % Sum of three signals
plot(time,x)
xlabel('Time (s)') % x-axis label
ylabel('Amplitude') % y-axis label
title('Sum of Sampled Signals') % title
figure;
X=fftshift(fft(x,nfft)); % FFT of sum of 3 signals
plot(nf,abs(X))
xlabel('frequency(Hz)') % x-axis label
ylabel('Magnitude') % y-axis label
title('Frequency Response') % title
I need help getting this last section into a for loop, i can not figure it out and need help. The graph labeled "frequency response" is the correct graph I need however i need the means of getting that graph to be from a for loop.
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Descriptive Statistics dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!