MATLAB Answers

Plot tabel in a loop

11 views (last 30 days)
gaetano mallardo
gaetano mallardo on 12 Apr 2019
Answered: A. Sawas on 13 Apr 2019
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');

  0 Comments

Sign in to comment.

Answers (1)

A. Sawas
A. Sawas on 13 Apr 2019
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));

  0 Comments

Sign in to comment.

Sign in to answer this question.

Tags