フィルターのクリア

Displaying Output in Command Window

2 ビュー (過去 30 日間)
Eli Wolkenstein
Eli Wolkenstein 2023 年 4 月 23 日
回答済み: Walter Roberson 2023 年 4 月 23 日
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)

回答 (1 件)

Walter Roberson
Walter Roberson 2023 年 4 月 23 日
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)
If you want more control over the format or number of decimal places, see compose or sprintf or fprintf

カテゴリ

Help Center および File ExchangeAxis Labels についてさらに検索

製品


リリース

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by