Explaining what MatLab is doing
Mostra commenti meno recenti
Hi Everyone,
In a Signals class and this is part of an already turned in Lab. I'm trying to better comprehend what MatLab is doing behind the scenes here and how the parameters/arguments are mapping inside of the programmatic language thorugh each step here into the array (or is it matrix) A_k.
This is Fourier analysis, and the different steps building along the way to get to A_k are confusing me a bit. Any detail would be greatly appreciated.
Below code is pasted, but also attached as .m file.
Thank you, friends...
%Part 1 Working within the Time Domain
% Import your waveform and time data
myID = 18042743; %Not my real ID
[Y_t, T_s ] = BuildingTraceData(myUFID);%BuildingTraceData was a p file
% Question 1
figure
plot(T_s, Y_t, LineWidth=1)
title('Time Domain of Vibrations')
ylabel('Amplitude')
xlabel('Time')
% Question 2
% The signal is periodic. The signal shows repetition with peaks at
% x=0.2959 y=34.5699 and x=0.3959 y=34.5699
x1=0.2959;
x2=0.3959;
% Question 3
T_0 = x2-x1;
T_0 = 0.1; % Fundamental Period (must fill in answer here)
%Question 4
f_0 = 1/T_0;
%Part 2 Fourier Series (Analysis)
% Question 5
% The below code is given as a starting point.
K = 10;
% Find Index point within Ts for the first T_o
[~,L_T_o]=min(abs(T_0-T_s)); %
%Pre-Allocation of space for Matrices (speeds up Matlab)
Kernel_R = zeros(K,L_T_o);
Kernel_I = zeros(K,L_T_o);
size(L_T_o);
L_T_o;
size(Kernel_I);
index=1:L_T_o;
% Calculation of coefficient matrix
% trapz was used as a way to approximate the integral
% help trapz may be useful to type into your command window
1/T_0;
f_0;
n=1;
for k = -K:K
Kernel_R(n,:) = Y_t(index).*cos(2*pi*k*T_s(index)*f_0);
Kernel_I(n,:) = Y_t(index).*sin(2*pi*k*T_s(index)*f_0);
A_R_k(n) = 1*f_0*trapz(T_s(index), Kernel_R(n,:)); % Real
A_I_k(n) = 1*f_0*trapz(T_s(index), Kernel_I(n,:)); % Imaginary
A_k(n)= A_R_k(n)-j*A_I_k(n); % j because EE
n=1+n ;
end
A_k
4 Commenti
埃博拉酱
il 19 Ott 2024
I strongly recommend that you start by asking an AI. AIs are very good at answering this kind of questions explaining the functionality and thought process of a code. If the AI's answer doesn't satisfy you, you can then ask a human expert for details.
Christina
il 21 Ott 2024
David Goodmanson
il 21 Ott 2024
Hello Christina.
AI can help, although you tend to end up with some pretty generic information. Good if it works. I have some doubts about the line [~,L_T_o]=min(abs(T_0-T_s)), which determines the maximum value of the index array 'index'. But since the data is not available from BuildingTraceData, it's not possible to run the code. It would help if you could attach the data, either as a mat file or (if the size is not large) a text file.
Christina
il 23 Ott 2024
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Time-Frequency Analysis in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!