Effacer les filtres
Effacer les filtres

Create array of all zeros

2 vues (au cours des 30 derniers jours)
Maryam Hamrahi
Maryam Hamrahi le 13 Juin 2016
Commenté : Azzi Abdelmalek le 13 Juin 2016
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

Réponse acceptée

Azzi Abdelmalek
Azzi Abdelmalek le 13 Juin 2016
Modifié(e) : Azzi Abdelmalek le 13 Juin 2016
c=zeros(10,1);
c=arrayfun(@(x) sprintf('%.4f',x),c,'un',0)
%or
c=zeros(10,1);
sprintf('%.4f\n',c)
  4 commentaires
Star Strider
Star Strider le 13 Juin 2016
It’s the aftermath!
Azzi Abdelmalek
Azzi Abdelmalek le 13 Juin 2016
@Maryam, If you don't want to print it, let it as it is, no one will see it!

Connectez-vous pour commenter.

Plus de réponses (1)

Star Strider
Star Strider le 13 Juin 2016
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.

Catégories

En savoir plus sur Mathematics dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by