Remove space between Matrix elements?

3 vues (au cours des 30 derniers jours)
Fred John
Fred John le 30 Déc 2014
Réponse apportée : dpb le 30 Déc 2014
Hi!
I have a Matrix which I copied over from Excel, but the problem is it has 2 extra horizontal spaces between elements then I would like it to have (I want 1 space between elements). The Matrix is 30x30 so a pain to remove spaces manually. Is there any quick way to achieve 1 space between the elements? Here is a snippet of the Matrix for example:
i
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
Thanks!

Réponses (1)

dpb
dpb le 30 Déc 2014
That's all a fignewton of the display formatting; there are no spaces internally.
At the command line, you can close up the spacing via something like
>> num2str(zeros(4),'%2d')
ans =
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
>>
The format command doesn't have the flexibility to specify a specific format string, only short as an option that has five digit precision iirc...

Catégories

En savoir plus sur Logical 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