MATLAB: How to add data to UItable from workspace

guide uitable

Hi. I am trying to make a table with 3 columns that would be made of 3 vectors. The first vectors contains file names, second vectors is the order of the files and third is used to define plotting offset. The last two vectors are generated from the length of the first vector. I was able to add names vector to the data table in the GUI, but I cant add additional vectors?
The only way I seen it done is by combing the 3 vectors together to make one vector, but I cant do that with horzcat as the first vector has strings in it and I can't seem to find a way to do that? Any suggestions?
The code I have right now looks like this
function update_xrddata(handles)
xrddata=evalin('base','xrddata');
L = length(xrddata);
for i = 1:L
xrdvars(i)=(xrddata(i).name);
end
xrdvars=xrdvars';
datasets=(1:L)';
offset=(1:L)';
names={'Name','Plot Order','Off-set'};
xrddats=horzcat(xrdvars,datasets,offset);
set(handles.data_table,'Data',xrddats,'RowName',xrdvars,'ColumnName',names)
xrdvars looks like this
'AD103.1'
'AD103.13 '
'AD103.15 '
'AD103.16 '
'AD103.4'
'AD103.5 '
'AD54.1 '
Thanks

Best Answer

xrddats = [xrdvars, num2cell([datasets, offset]) ];
Related Question