Borrar filtros
Borrar filtros

Presentation of results -- table

2 visualizaciones (últimos 30 días)
Richard
Richard el 26 de Dic. de 2011
Say I have a loop that something like:
for n=1:10,
var1(n)=var1(n-1)+5
var2(n)=2*var1(n)
var3=... so on
end
I want to print the values of var1,2,3 from every iteration and present them in a table. How might I do that?
Thank you.

Respuesta aceptada

Image Analyst
Image Analyst el 27 de Dic. de 2011
If you want to get fancy you can use a uitable control.
hTable = uitable();
columnHeaders = {'n', 'Random1', 'Random2'};
for n=1:10,
rowHeaders{n} = sprintf('Row %d', n);
tableData(n,1) = n
tableData(n,2) = rand(1,1);
tableData(n,3) = rand(1,1);
end
% Display the table of values.
set(hTable, 'RowName', rowHeaders);
set(hTable, 'ColumnName', columnHeaders);
set(hTable, 'data', tableData);
  2 comentarios
KSSV
KSSV el 27 de Dic. de 2011
Good...What if I want to change the size of table?
Image Analyst
Image Analyst el 27 de Dic. de 2011
Add these two lines to change the size of the table:
set(hTable, 'units', 'normalized');
set(hTable, 'Position', [.1 .1 .8 .8]);
To change the size of the columns within the table, there is a 'ColumnWidth' property that you can experiment around with.

Iniciar sesión para comentar.

Más respuestas (1)

Walter Roberson
Walter Roberson el 26 de Dic. de 2011

Categorías

Más información sobre Debugging and Analysis en Help Center y File Exchange.

Etiquetas

Aún no se han introducido etiquetas.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by