Approximate the variable in the workspace to one digite ?
Mostrar comentarios más antiguos
Hi all
I am have 1000 variables in the workspace, each one have five digits after the comma like 50,44444
How aproximated all 1000 variables to one digit after the comma like 50,4 ? because I cant chang each one individually ? so difficult!
Respuesta aceptada
Más respuestas (2)
Star Strider
el 19 de Nov. de 2014
1 voto
See the documentation for format. You can set the numeric display to one of several options. (The data themselves are all stored to the same precision, so the display precision does not affect the data precision.)
Image Analyst
el 19 de Nov. de 2014
Use the round function:
m=rand(4) % Tons of digits.
m1 = round(m, 1) % Round to first digit.
Hopefully your thousands of variables are in an array and not truly thousands of separate variables, which would be bad programming practice.
1 comentario
David Young
el 19 de Nov. de 2014
Well I learnt something from that! I hadn't noticed the new optional arguments for round()!
Categorías
Más información sobre Workspace Variables and MAT Files en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!