"To Workspace" block rounding numbers
Show older comments
I am trying to extract the final values from a Simulink simulation so that I can take to a Spreadsheet. However, when I use the "To Workspace" block, it is rounding my numbers and missing a lot of significant figures - is there a way to fix this or an alternative approach to extracting the final data point without rounding?
2 Comments
John D'Errico
on 21 May 2026
Edited: John D'Errico
on 21 May 2026
Are you positive this is not just a question of display precision, instead of how the number is actually stored? For example...
pi
And, yes, unless you are on a school board in some districts, you know that is not the true value of pi. (And, if you are on a school board, you probably think pi is only 3 anyway.) In fact, MATLAB stores approximately 16 decimal digits in floating point. (52 binary bits, if you wish.)
num2str(pi,20)
The final 3 digits of that result are incorrect as I recall.
You can see more digits in MATLAB, merely by use of the format command.
format long g
pi
Mathieu NOE
on 27 May 2026
I don't believe there is a problem with the "To Workspace" block itself , by default it should be a double precision format unless you have a different data format - pls double check your data format that you export.
supported Data Types : Boolean | bus | double | enumerated | fixed point | half | integer | single | string
in this simple demo I just store the last value (red rectangle) of my sine wave

what you see on matlab command window depends of the format (display) option - as already explained above by John.
because the default format may be "short" , you only see the first digits after the comma , but the number is still stored with maximal numerical precision (according to your data format )
out.simout.Datas = -0.5440 (matlab command window display with standard "short" format)
let's see more digits :
num2str(out.simout.Data,20) = '-0.54402111088936977445'
Answers (0)
Categories
Find more on String in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!