Filter löschen
Filter löschen

How to matlab display matrix in different way

60 Ansichten (letzte 30 Tage)
Sachin Pagar
Sachin Pagar am 3 Jul. 2020
Kommentiert: Walter Roberson am 3 Jul. 2020
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.

Antworten (2)

Walter Roberson
Walter Roberson am 3 Jul. 2020
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 am 3 Jul. 2020
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 Kommentar
Walter Roberson
Walter Roberson am 3 Jul. 2020
I do not understand what the question is?
Perhaps the answer is something like
fprintf('The RESULT is:');
fprintf(' %d', B);
fprintf('\n');

Melden Sie sich an, um zu kommentieren.

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by