Matlab rounding my values without me wanting it

4 Ansichten (letzte 30 Tage)
Martin
Martin am 26 Aug. 2019
Kommentiert: Martin am 26 Aug. 2019
Hello, this basically frustrates me a bit, - if I have:
Price = 20074.5;
And I present it in my table like this:
disp(table(Price,'VariableNames',{'answer'}));
answer
_____
20075
I dont get decimals? Anyone know a way around this? I hope there can be some kind of solution without format long/short because I don't want to touch other things
- Best

Antworten (1)

Walter Roberson
Walter Roberson am 26 Aug. 2019
You get that when format short or format short g or format rat or format hex is in effect.
To work around this without changing your active format, you will need to edit the function getFloatFormats() at roughly line 427 of file toolbox/matlab/datatypes/@tabular/disp.m
  6 Kommentare
Walter Roberson
Walter Roberson am 26 Aug. 2019
function disptable(Table)
old_format = matlab.internal.display.format;
format long
disp(Table)
format(old_format)
end
Martin
Martin am 26 Aug. 2019
This work but unfortunately it makes the other values in the table very long :/. I only gave a simple table but there are like 20 columns. E.g. I got a percent column where I just need it to show 0.93 but with format long it show:
0.931214019188181

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Matrices and Arrays finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by