How to matlab display matrix in different way
조회 수: 111 (최근 30일)
이전 댓글 표시
matlab display matrix is very problenatic question. my question is How to matlab display matrix as image and Table
example:
For example:
B = magic(3)
disp('The ANS is:')
disp(B)
then how I can display I am see the ans on matlab but i need in detailed.
댓글 수: 0
답변 (2개)
Walter Roberson
2020년 7월 3일
To display as an image on the screen, then you can do things like
for K = 1 : 3; text(0.25*K, 0.5, string(B(:,K))); end
If you want to construct an image in an array (such as you might want to use as a frame of a movie) then use Computer Vision's insertText() to insert each item into the appropriate position in the array.
In MATLAB, there are multiple things that are called "tables".
table() objects:
disp(array2table(B))
uitable() graphic object:
h = uitable('Position', [x y width height], 'Data', B)
The exact syntax used there can only be used with "traditional figures". If you add the container to display into and that container is part of a uifigure() then additional formatting options become available; https://www.mathworks.com/help/matlab/ref/matlab.ui.control.tableappd.addstyle.html
Some people also refer to formatted text output as "tables". Formatted text can be created by sprintf() or compose(), and the displayed with fprintf() or disp(), or you can create formatted items directly to text display with fprintf()
댓글 수: 0
Sachin Pagar
2020년 7월 3일
댓글 수: 1
Walter Roberson
2020년 7월 3일
I do not understand what the question is?
Perhaps the answer is something like
fprintf('The RESULT is:');
fprintf(' %d', B);
fprintf('\n');
참고 항목
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!