how to print matrix with fprintf

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

답변 (1개)

Walter Roberson
Walter Roberson 2017년 9월 3일

1 개 추천

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

카테고리

도움말 센터File Exchange에서 Aerospace Blockset에 대해 자세히 알아보기

태그

질문:

2017년 9월 3일

답변:

2017년 9월 3일

Community Treasure Hunt

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

Start Hunting!

Translated by