0

I am still trying to update the row names of a uitable in a matlab gui. I previously asked you about this (https://stackoverflow.com/questions/21585453/update-rows-name-of-uitable-in-matlab-gui). However, I am writing you again in order to let you know that I am not able to solve this problem.

This is the part of my code where I am stuck:

function SavePushButton_Callback(~,~)

%%##
data{1,1}= get(h5Out,'string');
data{1,2}= get(h6Out,'string');
data{1,3}= get(h7Out,'string');
data{1,4}= get(h8Out,'string');

===============================
% Update the data %
oldData = get(t,'Data');
newRow =  cat(0,data,cell(0,size(data,2)));
newData2 = [oldData; newRow];
set(t,'Data',newData2);

===============================
% this part of the code should Update the name of the rows %
rowname = get(h1Out,'string');
NewRowName = cat(0,rowname,cell(0,size(rowname,1)));
rowname2= [rowname; NewRowName];
set(t,'Rowname',rowname2);

end
Community
  • 1
  • 1
Hector
  • 275
  • 6
  • 16

1 Answers1

0

It looks like the function to set the Rowname is expecting a cell array of strings, however you're giving it a cell array of cells, which themselves contain strings. This is because the get function (for example data{1,1}= get(h5Out,'string'); ) is already returning a cell array containing a string, and you're storing it within another cell array ( data ). Use () instead of {} on the data matrix in order to concatenate the individual cells into one single cell matrix. In other words, change:

data{1,1}= get(h5Out,'string');
data{1,2}= get(h6Out,'string');
data{1,3}= get(h7Out,'string');
data{1,4}= get(h8Out,'string');

to:

data(1,1)= get(h5Out,'string');
data(1,2)= get(h6Out,'string');
data(1,3)= get(h7Out,'string');
data(1,4)= get(h8Out,'string');
DMR
  • 1,479
  • 1
  • 8
  • 11
  • Dear @DMR, Thank you very much for your kind help. I tried your suggestion, and unfortunately it does not work. this is the response I get from matlab: Assignment has more non-singleton rhs dimensions than non-singleton subscripts Error in Gui_Table/SavePushButton_Callback (line 215) data(1,2)= get(h6Out,'string'); Error while evaluating uicontrol Callback. Do you have any Idea how to solve this problem? Thank you very much. Héctor – Hector Feb 08 '14 at 12:08