Error/Mismatch in determing impedance using fft in simulink imported data.
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 ohmsn’, 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 cricial.
Your help will be really appreciated.
Thank You.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 ohmsn’, 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 cricial.
Your help will be really appreciated.
Thank You. 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 ohmsn’, 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 cricial.
Your help will be really appreciated.
Thank You. simulink, fft, import, to workspace, impedance, simscape MATLAB Answers — New Questions