How to prevent rounding number
27 ビュー (過去 30 日間)
古いコメントを表示
Hello everyone, I have a trouble about rounding. This is my example: I assign K=173.1227 but the numerator the transfer function G is 173.1. When I try K=173.227, the num of G is 173.2. How can I fix that? I try to format long and go to preferences to adjust the variable and command windows but that doesn't work. Please help me! TIA
0 件のコメント
採用された回答
Walter Roberson
2023 年 5 月 16 日
G1 = tf(173.1227, conv([1 0.2], [1 8 20]))
format long g
G1.numer
The transfer function itself is not using the rounded values. The rounded values are only for display purposes.
The internal code does not offer any way to configure the number of significant digits: it always uses %.4g format for non-integers.
2 件のコメント
Walter Roberson
2023 年 5 月 16 日
Sorry, I am not familiar with margin or "k neutral limitation"
format long g
G=tf([1],conv([1 0.2],[1 8 20]))
K = margin(G)
その他の回答 (1 件)
FannoFlow
2023 年 5 月 16 日
Your data is still there, its just not printing out the full precision.
See also:
K2 = 173.227;
G2 = tf([K2, conv(1, 0.2)], [1, 8, 20])
G2.numerator
G2.denominator
2 件のコメント
Walter Roberson
2023 年 5 月 16 日
The calculations for the transfer function use the full precision of the values you use to construct the transfer function (or state space system)
Only the display of the transfer function is affected.
参考
カテゴリ
Help Center および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!