How to print results from damp() to text file

2 Ansichten (letzte 30 Tage)
Albert Garcia
Albert Garcia am 22 Sep. 2018
Beantwortet: Thomas Marcus am 3 Jan. 2022
I was trying to print the results from the damp() function to a text file using fprintf, but fprintf doesn't support it.
I would like to be able to maintain that same format that you see in the command window when printing it to a text file as well.
The following is a sample of what I would like to be able to output into a separate txt file
damp(tf(1,[12 16 560 180])
  4 Kommentare
Walter Roberson
Walter Roberson am 22 Sep. 2018
>> which damp
/Applications/MATLAB_R2018b.app/toolbox/shared/controllib/engine/damp.m
Albert Garcia
Albert Garcia am 22 Sep. 2018
I have no idea. I'm using R2017. I think that I am using the damp(sys). I see two options, one with damp(A,ts) and another with damp(sys), and the one that shows up in command window is damp(sys). Does this answer your question?

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 22 Sep. 2018
evalc() the function to capture the text.
  3 Kommentare
Walter Roberson
Walter Roberson am 22 Sep. 2018
A=evalc('damp(tf(1,[12 16 560 180])');
Note that this will result in a character vector stored in A that will have embedded newline (\n) characters in it, but not embedded carriage returns (\r) .
Albert Garcia
Albert Garcia am 22 Sep. 2018
This works great, thank you :D

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Thomas Marcus
Thomas Marcus am 3 Jan. 2022
To get more accurate numbers than what is printed on screen, use [wn, zeta, p] = damp(sys) to get the arrays.

Kategorien

Mehr zu MATLAB finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by