I use "zeros" to create a matrix with all zeros.
but I want to create matrix with all 0.0000
is there any way for doing this?
c=zeros(10,1);
I would like to have all 0.0000
Thank you very much

 Respuesta aceptada

Azzi Abdelmalek
Azzi Abdelmalek el 13 de Jun. de 2016
Editada: Azzi Abdelmalek el 13 de Jun. de 2016

1 voto

c=zeros(10,1);
c=arrayfun(@(x) sprintf('%.4f',x),c,'un',0)
%or
c=zeros(10,1);
sprintf('%.4f\n',c)

4 comentarios

Maryam Hamrahi
Maryam Hamrahi el 13 de Jun. de 2016
many thanks.
I do not want to print it. Just a matrix with all array 0.0000
John D'Errico
John D'Errico el 13 de Jun. de 2016
Is there a difference between 0 and 0.0000? Is that the new math?
Star Strider
Star Strider el 13 de Jun. de 2016
It’s the aftermath!
Azzi Abdelmalek
Azzi Abdelmalek el 13 de Jun. de 2016
@Maryam, If you don't want to print it, let it as it is, no one will see it!

Iniciar sesión para comentar.

Más respuestas (1)

Star Strider
Star Strider el 13 de Jun. de 2016

2 votos

They all are. What you see depends on the display format you choose.
To see all the zeros, type:
format long g
in the Command Window or in your script.

Categorías

Más información sobre MATLAB en Centro de ayuda y File Exchange.

Preguntada:

el 13 de Jun. de 2016

Comentada:

el 13 de Jun. de 2016

Community Treasure Hunt

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

Start Hunting!

Translated by