Matlab Live Script Format Problem
18 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hello!
I have a some problem. I want to see the result on shortEng format. But I cant do it.
0 Kommentare
Antworten (2)
Cris LaPierre
am 30 Okt. 2020
Bearbeitet: Cris LaPierre
am 30 Okt. 2020
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)
Another option is to convert the symbolic number to double.
[S_az,Unit] = separateUnits(S_az);
S_az = double(S_az)
Walter Roberson
am 30 Okt. 2020
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.
Siehe auch
Kategorien
Mehr zu Logical 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!