Borrar filtros
Borrar filtros

Euler's Formula and FFT

8 visualizaciones (últimos 30 días)
Seweryn
Seweryn el 2 de Nov. de 2023
Comentada: Sulaymon Eshkabilov el 4 de Nov. de 2023
Hi guys, from the .csv file, I performed an FFT analysis in Simulink and obtained the following equations (pdf file). Take this equation (screen 1) for example, can I expand it to this form (screen 2)? I know, I can use e^ix = cos(x) + isin(x) but i don't know how to do that. Thanks in advance!
Best regards,
Seweryn

Respuesta aceptada

Sulaymon Eshkabilov
Sulaymon Eshkabilov el 2 de Nov. de 2023
Editada: Sulaymon Eshkabilov el 2 de Nov. de 2023
If understood correctly, you are trying to find a non-linear fit of the large flacturations using sine and cosine functions. If so, here is how it can be attained:
% Data import
D = readmatrix('tek0005.csv');
D(1:15, :) = []; % Data cleaning
f1 = 2; % found using fft
Model = @(a, t)(a(1)*sin(2*pi*f1*t)+a(2)*cos(2*pi*f1*t));
t = D(:,1);
y1 = D(:,2); % Channel 1
a0 = [1 1]; % Initially estimated guess values for coeff a
Coeffs1 = nlinfit(t, y1, Model, a0);
a = Coeffs1; % Found fit model coeffs
y_fit = (a(1)*sin(2*pi*f1*t)+a(2)*cos(2*pi*f1*t));
figure(1)
plot(t, y1, 'r')
hold on
plot(t, y_fit, 'k--', 'LineWidth',2)
legend('Data: CH1', 'Fit Model')
ylabel('Channel 1')
xlabel('Time')
hold off
% Similarly, you can do for the other channel data
f1 = 2; % found from fft
t = D(:,1);
y2 = D(:,3);
% NB: mean of y2 is NOT "0". Thus, it should be removed from y2 or added to the fit model!
a0 = [1 1]; % Initially estimated guess values for coeff a
Coeffs = nlinfit(t, y2, Model, a0)
Coeffs = 1×2
-0.0335 -0.0016
a = Coeffs;
y_fit = (a(1)*sin(2*pi*f1*t)+a(2)*cos(2*pi*f1*t))+mean(y2);
figure
plot(t, y2, 'b')
hold on
plot(t, y_fit, 'k--', 'LineWidth',2)
legend('Data: CH2', 'Fit Model')
ylabel('Channel 2')
xlabel('Time')
hold off
  3 comentarios
Seweryn
Seweryn el 4 de Nov. de 2023
Editada: Seweryn el 4 de Nov. de 2023
I need the form of equations like you used above: (a(1)*sin(2*pi*f1*t)+a(2)*cos(2*pi*f1*t))+mean(y2);
Sulaymon Eshkabilov
Sulaymon Eshkabilov el 4 de Nov. de 2023
I posted my answer code for a shorter fit model with sine fcn only in your new post.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Spectral Measurements en Help Center y File Exchange.

Productos


Versión

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by