Hi,
I would like to extract the values of frequency and amplitude
from a fft and save them in separated tables.
For example, for the wave y = A1*sin(2*pi*w1*t) + A2*sin(2*pi*w2*t);
I would have the tables:
1) F, with the values w1 and w2 and another table
2) A, with the values A1 and A2.
I run the script below to ONLY DISPLAY the frequencies and amplitudes
but I don't know how to extract and save.
I wonder if someone have experience on how to write some lines to perform
this action.
Thank you in advance
Emerson
SCRIPT TO DISPLAY F AND A:
clear all;close all;%Wave properties
w1=5; % Frequency1 (Hz)
A1=1; % Amplitude1 (dimensionless)
w2=1; % Frequency2 (Hz)
A2=5; % Amplitude2 (dimensionless)
% Time properties
Datapoints = 1000; % Number of recorded data;
Length=10; % Length (seconds);
Step= Length/Datapoints; % Fraction of seconds
t = (0:Datapoints-1)*Step; % Time vector
% Sum of a w1-Hz sinusoid and a w2-Hz sinusoid
y = A1*sin(2*pi*w1*t) + A2*sin(2*pi*w2*t); % Fourier Transformation
NFFT = Datapoints; % Next power of 2 from length of y
Y = fft(y,NFFT)/Datapoints;fs=Datapoints/Length; f = fs/2*linspace(0,1,NFFT/2+1);% Plot single-sided amplitude spectrum.
plot(f,2*abs(Y(1:NFFT/2+1))) axis([0 6 0 6])title('Single-Sided Amplitude Spectrum of y(t)')xlabel('Frequency (Hz)')ylabel('Amplitude - |Y(f)|')
Best Answer