how to remove trailing zeros after rounding a matrix?

I need to round a matrix to two decimal places but I want to get rid of those trailing zeros after the decimal point. Even I want to use that matrix for plotting also? How to do it?

Respuestas (1)

Stephan
Stephan el 21 de Abr. de 2021
Editada: Stephan el 21 de Abr. de 2021
format short
A = 1.23
A = 1.2300
format shortG
A = 1.23
A =
1.23

5 comentarios

Deepthi B
Deepthi B el 21 de Abr. de 2021
Sir, again in the workspace it's showing a as 1.2300. I want a to be 1.23 in the wrokspace also
Stephan
Stephan el 21 de Abr. de 2021
There is no way to show it in workspace the way you want. Then you would have to use some dirty tricks such as save it as char or sym - but is it worth this only because of the trailing zeros?
Deepthi B
Deepthi B el 21 de Abr. de 2021
Sir, I need to plot like this, because of this trailing zeros I am getting 1.00. I want it to be 1.
Stephan
Stephan el 21 de Abr. de 2021
Can you provide the code?
Deepthi B
Deepthi B el 21 de Abr. de 2021
x =1:1:12;
y = gcmmodels;
subplot(2,2,1)
heat(round(clusteringcoefficientfive,2), x, y,'%0.2f','FontSize', 11,'TickAngle', 0,'ShowAllTicks', true, 'TickFontSize', 10,'GridLines', ':');
subplot(2,2,2)
heat(round(clusteringcoefficientsix,2), x, y,'%0.2f','FontSize', 11,'TickAngle', 0,'ShowAllTicks', true, 'TickFontSize', 10,'GridLines', ':');

Iniciar sesión para comentar.

Categorías

Más información sobre Operators and Elementary Operations en Centro de ayuda y File Exchange.

Preguntada:

el 21 de Abr. de 2021

Comentada:

el 21 de Abr. de 2021

Community Treasure Hunt

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

Start Hunting!

Translated by