How to export a bode plot magnitude and phase to excel

21 vues (au cours des 30 derniers jours)
Gerald Merits
Gerald Merits le 21 Juin 2017
Commenté : dpb le 23 Juin 2017
I am very new to Matlab. The transfer function I am working with is much more difficult than the one below, but what I want to do will is not impacted by the function. I have a bode plot I am generating:
H = tf([1 0.1 7.5],[1 0.12 9 0 0]);
bode(H)
I get a plot of magnitude in dB and phase in degrees, both across rad/sec. I am looking for absolute magnitude (not dB), radians (not degrees) and the the x-axis should he Hertz. I am then wanting to export the data into Excel (magnitude in the first column and phase in the second) from, for example, 10Hz to 100Hz in 10Hz steps. Can someone please assist me in doing this. It would be greatly appreciated. Thanks!
  2 commentaires
dpb
dpb le 21 Juin 2017
See <MLT#answer_107017>. Basically, just save the optional outputs of magnitude and phase and scale them.
Gerald Merits
Gerald Merits le 22 Juin 2017
How does one save the outputs? I am allowed to save the image itself, but not export the outputs or define the starting frequency, ending frequency, and frequency steps for output into a text file or Excel? That is where I am stuck. Thanks for the answer.

Connectez-vous pour commenter.

Réponse acceptée

Star Strider
Star Strider le 22 Juin 2017
I would create a table from the bode output, and then use the writetable (link) function:
H = tf([1 0.1 7.5],[1 0.12 9 0 0]);
w_v = [10:10:100]*2*pi; % Vector Of Radian Frequencies
[mag,phs,RadianFrequency] = bode(H, w_v);
Magnitude = squeeze(mag);
Phase = squeeze(phs);
T = table(RadianFrequency,Magnitude,Phase)
Then use writetable to your Excel file. The headers and column information will all be there.
  1 commentaire
dpb
dpb le 23 Juin 2017
writetable is handy indeed; I wondered why TMW didn't do something like it much sooner than now. That it needs the intermediate table is a little less than ideal as generic i/o routine, but is better than having to fight cell arrays with functions that are not cell-array aware.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Plot Customization dans Help Center et File Exchange

Produits

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by