Transfer from Decimal to Percentage?
조회 수: 14 (최근 30일)
이전 댓글 표시
Hi guys,
I have a Matrix A =
[1 2 3
4 5 6
7 8 9]
How I can get Matrix B =
[100% 200% 300%
400% 500% 600%
700% 800% 900%]?
Sprintf might work but I don't know how to use it. Thanks in advance.
댓글 수: 2
Walter Roberson
2012년 6월 25일
You cannot get it as a numeric matrix, as numeric matrices cannot contain '%' characters.
채택된 답변
Walter Roberson
2012년 6월 25일
thisfmt = [ repmat(' %.3f%%', 1, size(A,2)) '\n'];
B = sprintf( thisfmt, A.' );
B(1) = '[';
B(end) = ']';
This creates the output as a single string.
댓글 수: 8
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!