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.
.
추가 답변 (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!
