Displaying Output in Command Window
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
How can I display the outputs for the variables dr through ts in the command window neatly? (every line will say the name of the variable and show its value)
a1=input('A1: ');
t1=input('t1: ');
a2=input('A2: ');
t2=input('t2: ');
dr=log(a1/a2)/sqrt((4*pi^2)+(log(a1/a2)^2));
T=t2-t1;
wn=(2*pi)/(T*sqrt(1-dr^2));
wd=wn*sqrt(1-dr^2);
Mp=exp((pi*dr)/sqrt(1-dr^2));
tp=pi/wd;
tr100=(pi-atan(-dr*sqrt(1-dr^2))/wn*sqrt(1-dr^2));
tr90=(0.8+2.5*dr)/wn;
ts=4/(dr*wn);
X=[' Damping Ratio: ',dr,' Period: ',T,' Undamped Frequency: ',wn,' Damped Frequency: ',wd,' Maximum Overshoot: ',Mp,' 0-100% Rise Time: ',tr100,' 10-90% Rise Time: ',tr90,' Settling Time: ',ts];
disp(X)
0 Kommentare
Antworten (1)
Walter Roberson
am 23 Apr. 2023
One way would be
X = " Damping Ratio: " + dr + " Period: " + T + " Undamped Frequency: " + wn + " Damped Frequency: " + wd + " Maximum Overshoot: " + Mp + " 0-100% Rise Time: " + tr100 + " 10-90% Rise Time: " + tr90 + " Settling Time: " + ts;
For values that are not integers, the number of significant digits that this will use after the decimal place is a bit variable (generally 4)
0 Kommentare
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!