How to plot LTspice graph in Matlab in this case?
14 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Huihong
le 15 Août 2023
Commenté : Star Strider
le 16 Août 2023
Hello,
I'm trying to use matlab to plot the bode plot exported from LTspice. The .txt file as well as my code is added below. I wonder why matlab keep warning me that "plot" is not proper, but I can't fix it. I really appreciate it if anyone can tell me how to solve it. And my code is listed below.
plot (Freq1,Vvo1);
hold on
xlabel('Freq (Hz)');
ylabel('Magnitude (dB)');
grid on
0 commentaires
Réponse acceptée
Star Strider
le 15 Août 2023
One approach —
T1 = readtable('final_all1.txt', 'VariableNamingRule','preserve')
T1.MagdB = str2double(extractBetween(T1{:,2},'(','dB'));
T1.PhaseDeg = str2double(extractBetween(T1{:,2},',','°'))
figure
subplot(2,1,1)
semilogx(T1.('Freq.'), T1.MagdB)
grid
ylabel('Magnitude (dB)')
subplot(2,1,2)
semilogx(T1.('Freq.'), T1.PhaseDeg)
ylabel('Phase (°)')
grid
xlabel('Frequency')
sgtitle('Bode Plot of LTSpice Data')
There may be more efficient ways to extract the data, however this works.
To unwrap the phase data:
T1.PhaseDegU = rad2deg(unwrap(deg2rad(T1.PhaseDeg)))
and plot that instead for the phase. Otherwise, just leave it as it is.
.
2 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Polar Plots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
