Plot tabel in a loop

1 次查看(过去 30 天)
gaetano mallardo
gaetano mallardo 2019-4-12
回答: A. Sawas 2019-4-13
I have a code to plot a table, but i am not able to generate it in a loop as the "dat vector" is made of double and array.
There is a way to generate everything in loop?
f = figure();
set(f,'Position',[500 500 300 200]);
%data=['cyl/racc', 'foro', 'piano'];
dat = { ' cyl', meanErr(1), radius(1);...
' cyl', meanErr(2),radius(2);...
' piano', meanErr(3),radius(3);...
' piano', meanErr(4),radius(4);...
' piano', meanErr(5),radius(5);...
' piano', meanErr(6),radius(6);...
' piano', meanErr(7),radius(7);...
' cyl', meanErr(8),radius(8);...
' cyl', meanErr(9),radius(9);...
' cyl', meanErr(10),radius(10);...
' cyl', meanErr(11),radius(11);...
' piano', meanErr(12),radius(12);...
};
columnname = {'Parameter', 'meanError','Radius'};
columnformat = {'char', 'numeric', 'numeric'};
t = uitable('Units','normalized','Position',...
[0.05 0.05 0.755 0.87], 'Data', dat,...
'ColumnName', columnname,...
'ColumnFormat', columnformat,...
'RowName',[]);
title('Modello testcase mesh 35k nb lv2');

回答(1 个)

A. Sawas
A. Sawas 2019-4-13
It seems that the first column of dat is a text label then you can define a cell array of the possible lables and create a double vector of label indices. Then dat can be found as following:
label_list = {'cyl/racc'; 'foro'; 'piano'};
data_labels = [1,1,3,3,3,3,3,1,1,1,1,3]; % 1 and 3 are the indices of the labels 'cyl' and "piano" in the label_list
dat = table2cell(table(label_list(data_labels), meanErr, radius));

类别

Help CenterFile Exchange 中查找有关 Just for fun 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by