Printing table susing fprintf
조회 수: 2 (최근 30일)
이전 댓글 표시
I have the following script; my problem is that I cannot get all the values in A under column A in the frprintf. Any ideas?
A=[1;3;2;8;9]; B=2*pi*A; fprintf('A B\n'); fprintf('======\n'); fprintf('%d %d\n',A,B);
댓글 수: 0
채택된 답변
Jan
2017년 3월 14일
편집: Jan
2017년 3월 14일
Use:
fprintf('%d %d\n', [A, B].');
Then the elements of A and B appear alternating in the provided array:
C = [A, B].';
C(:)
Note that Matlab addresses the matrix in columnwise order.
With the original command fprintf('%d %d\n',A,B); Matlab uses the format string to print all elements of A at first and then all of B, but not alternating.
댓글 수: 0
추가 답변 (1개)
Erick Miranda
2020년 1월 29일
Thank you, thank you...
fprintf('%d %d\n', [A, B].');
I have a question what is, or how does it work " .' "
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!