
Plotting a bode graph extracted from LTSPICE simulator
10 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Juan Carlos Maturana Renteria
il 27 Ago 2020
Commentato: Star Strider
il 27 Ago 2020
hi,
i'm trying to plot a bode graph but at the moment of show in it on matlab the graph doesn't show up, but just the axes thought. What happen is that the 'D' variable is just saving the first row, but not the rest. I have been looking on the documentation of 'textscan' and it says that if the parameter 'formatSpec' doesn't match with the text field, it will throw a error and save the the prebius rows, yet my every rows in the .text is the same.
Here is my code (text field attached) if maybe it's someting wrong with it. I will really apreciate the help.
archivo = fopen('DatosBodeFinal.txt');
Dc = textscan(archivo, '%f (%fdB,%f°)','CollectOutput',1);
fclose(archivo);
D = cell2mat(Dc);
disp(Dc);
figure
subplot(2,1,1);
semilogx(D(:,1), D(:,2),'Color','k','LineWidth',3);
ylabel('Amplitude (dB)');
grid
subplot(2,1,2);
semilogx(D(:,1), D(:,3),'Color','k','LineWidth',3);
ylabel('Phase (°)');
grid
xlabel('Frequency');
0 Commenti
Risposta accettata
Star Strider
il 27 Ago 2020
This works for me:
filename = 'DatosBodeFinal.txt';
fidi = fopen(filename, 'rt');
Dc = textscan(fidi, '%f(%fdB,%f°)', 'CollectOutput',1);
D = cell2mat(Dc);
figure
subplot(2,1,1)
semilogx(D(:,1), D(:,2))
title('Amplitude (dB)')
grid
subplot(2,1,2)
semilogx(D(:,1), D(:,3))
title('Phase (°)')
grid
xlabel('Frequency')
and produces this plot:

.
2 Commenti
Star Strider
il 27 Ago 2020
As always, my pleasure!
I have no idea what the problem may be with your other files, that I assume are also LTSPICE files. If they have the same format as this one, my code should work with them. Your Question is the second about LTSPICE files that I have replied to (you already discovered the other one), and the same code worked with both of them. That is also the same code I used here. It may be the version of MATLAB you are using, so also be ccertain you have the latest Updates. (I am using R2020a, however this code also worked with whatever version worked with the previous Question, that I believe was R2019a, although I do not remember just now.)
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Annotations in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!