Matlab Live Script Format Problem

13 ビュー (過去 30 日間)
Mehmet SARIARSLAN
Mehmet SARIARSLAN 2020 年 10 月 30 日
編集済み: Cris LaPierre 2020 年 10 月 30 日
Hello!
I have a some problem. I want to see the result on shortEng format. But I cant do it.

回答 (2 件)

Cris LaPierre
Cris LaPierre 2020 年 10 月 30 日
編集済み: Cris LaPierre 2020 年 10 月 30 日
This is likely because your value does not have an exact decimal equivalent. Since the result is symbolic, you are getting the exact representation. If you want to keep the units, use vpa and specify the number of digits to show.
u=symunit;
S_z=2*u.mm;
S_k1=205*u.mm;
N_tvs=231;
S_az=sqrt(3)/2*(S_k1+S_z).^2.*N_tvs;
S_az=unitConvert(S_az,u.m^2);
vpa(S_az,4)
ans = 
8.572m2
Another option is to convert the symbolic number to double.
[S_az,Unit] = separateUnits(S_az);
S_az = double(S_az)
S_az = 8.5720
  1 件のコメント
Mehmet SARIARSLAN
Mehmet SARIARSLAN 2020 年 10 月 30 日
Thank you so much!

サインインしてコメントする。


Walter Roberson
Walter Roberson 2020 年 10 月 30 日
Symbolic values are never output in shortEng format.
About the closest you will be able to get is
digits(5)
vpa(S_az)
This will give the same number of digits after the decimal place as shortEng would. However, this will not switch to engineering notation until values are at least +/- 1e6, and it will not group by multiples of 3.
I seem to recall that several years ago someone (probably either Jan or Stephen) posted a routine to format non-symbolic numbers in engineering notation. If you had a routine such as that, then you could use it in conjunction with the obscure mapSymType call... (mumble, mumble, mumble...)
In short... it is certainly not easy.
  1 件のコメント
Mehmet SARIARSLAN
Mehmet SARIARSLAN 2020 年 10 月 30 日
Thank you so much!

サインインしてコメントする。

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by