How to plot LTspice graph in Matlab in this case?
14 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
採用された回答
Star Strider
2023 年 8 月 15 日
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 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Polar Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
