How to matlab display matrix in different way

조회 수: 111 (최근 30일)
Sachin Pagar
Sachin Pagar 2020년 7월 3일
댓글: Walter Roberson 2020년 7월 3일
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.

답변 (2개)

Walter Roberson
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()

Sachin Pagar
Sachin Pagar 2020년 7월 3일
For example
A = magic(3)
disp(['The RESULT is: [' num2str(B(:).') ']']) ;
Display:
The RESULT is: [8 3 4 1 5 9 6 7 2]
second another example
my matrix is in the forms:
MATHWORK = [15 25, 36 41,55 68] .
  댓글 수: 1
Walter Roberson
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');

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Images에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by