Error/Mismatch in determing impedance using fft in simulink imported data.
Afficher commentaires plus anciens
Hello Everyone
I need to calculate the impedance of a more or less complex circuit using FFT. I have implemented the circuit in simulink and saved the voltage and current in the workapace using To Workspace block. However, after performing fft , I didnt quite get the expected result. Now to check if my code was right, I was testing it on a simple circuit. I have implemented a simple RC circuit . The model is attached. To determine impedance I am using the theory Z(w)=fft(voltage)/fft(current). R=Real (Z(w), X=Imag(Z(w)).
Now, The snapshot of the circuit--

The code I am using-
clc
% clear
Time = out.tout;
Load_Voltage = out.V_L;
Load_Current = out.I_L;
Fs = 1 / mean(diff(Time));
N = length(Load_Voltage);
fft_Load_Voltage = fft(Load_Voltage);
fft_Load_Current = fft(Load_Current);
fft_Load_Voltage_single_sided = fft_Load_Voltage(1:N/2+1);
fft_Load_Current_single_sided = fft_Load_Current(1:N/2+1);
frequencies = Fs * (0:(N/2)) / N;
frequency_of_interest =13.56e6;
[~, index] = min(abs(frequencies - frequency_of_interest));
Z1 = fft_Load_Voltage_single_sided(index) / fft_Load_Current_single_sided(index);
R1 = real(Z1);
X1 = imag(Z1);
fprintf('R: %.2f ohms, X: %.2f ohms\n', R1, X1);
I have set the value of the resistor as 30 and the value of capacitor such as it would exibit -50 ohm at 13.56 Mhz, which is the driving frequency. But the results are off. The result I get is: R: 25.79 ohms, X: -37.52 ohms.
What is the problem here? Is it the code or anything with the simulink model. However if its just a resistive circuit the code gives correct result. This a very important step in a much bigger project. It is crucial.
Your help will be really appreciated.
Thank You.
2 commentaires
Pat Gipper
le 22 Mai 2024
Modifié(e) : Pat Gipper
le 22 Mai 2024
The model you attached and the picture that you show is a series RL circuit, with R = 50 Ohms and L = 0.587 uH.
Md. Golam Zakaria
le 23 Mai 2024
Réponse acceptée
Plus de réponses (1)
Pat Gipper
le 28 Mai 2024
1 vote
@Md. Golam Zakaria You can use the variable step solver and force it to output at fixed intervals by putting a "Sample time" value other than -1 into the "To Workspace" blocks of your simulation as shown in the image below. I tend to use a workspace variable instead of a fixed number for flexibility.

Catégories
En savoir plus sur Electrical Systems 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!
