How to matlab display matrix in different way

152 visualizaciones (últimos 30 días)
Sachin Pagar
Sachin Pagar el 3 de Jul. de 2020
Comentada: Walter Roberson el 3 de Jul. de 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.

Respuestas (2)

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

Iniciar sesión para comentar.

Categorías

Más información sobre Image Data Workflows en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by