Azzera filtri
Azzera filtri

how to print matrix with fprintf

12 visualizzazioni (ultimi 30 giorni)
Taehun Kim
Taehun Kim il 3 Set 2017
Risposto: Walter Roberson il 3 Set 2017
Hi all i want to ask how to print a matrix A below with fprintf function with %4d conversion specifier
A =
1 1 -1 1 1 -1 -1 1 1 1 -1 1
1 -1 1 -1 -1 1 1 1 1 -1 1 1
1 1 1 -1 1 -1 1 -1 -1 -1 -1 1
1 -1 1 -1 -1 -1 1 1 -1 -1 -1 1
1 1 -1 1 1 -1 -1 -1 1 -1 1 -1
1 -1 1 1 1 1 1 -1 -1 -1 1 -1

Risposte (1)

Walter Roberson
Walter Roberson il 3 Set 2017
fmt = [repmat('%4d ', 1, size(A,2)-1), '%4d\n'];
fprintf(fmt, A.'); %transpose is important!

Categorie

Scopri di più su Workspace Variables and MAT-Files in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by