Code Comments
Programming Forum and web based access to our favorite programming groups.Hello, I need to display the user data in the GUI, using some kind of table (data grid). I don't need the editing ability - all I need is to display them. As far as I know there's no such UI element in the Matlab itself, and here I've found only some ActiveX controls, but I'm working on Linux, so it's useless for me. Is there some way to display a simple table? Thanks a lot in advance. Tomas
Post Follow-up to this messageTomas Vondra wrote: > Hello, > > I need to display the user data in the GUI, using some kind of table > (data grid). I don't need the editing ability - all I need is to > display them. > > As far as I know there's no such UI element in the Matlab itself, and > here I've found only some ActiveX controls, but I'm working on Linux, > so it's useless for me. Is there some way to display a simple table? > > Thanks a lot in advance. > > Tomas If you have R14 ( sp2 ?? ) there is the command uitable. Do help uitable
Post Follow-up to this message>>Tomas
>
>
> If you have R14 ( sp2 ?? ) there is the command uitable. Do
>
> help uitable
>
I've had a little play with the object and I'm not too sure how usable
it is. Here is an example of it's use but it's a bit fiddly.
function out = use_table
data = rand(3);
colnames = {'X-Data', 'Y-Data', 'Z-Data'};
t = uitable(data, colnames,'Position', [20 20 250 100]);
t.DataChangedCallback = @change_fcn;
out = @get_data;
function out = get_data
out = data;
end
function change_fcn(src, ev)
row = ev.getEvent.getFirstRow;
col = ev.getEvent.getColumn;
d = src.TableModel.getValueAt(row,col);
data(row+1,col+1) = str2num(d);
end
end
The trick to make this more usable would be to create some
implementation of javax.swing.TableModel that has a friendly matlab back
end such like so that you can do the following somehow.
function use_table
data = rand(10);
% Create a uitable with a simple matlab data model. Specify
% that the cell class will be all of double.
t = uitable(@getfun, @setfun, 'double');
function val = getfun(t, row, col)
val = data(row,col);
end
function setfun(t, row, col, val)
data(row,col) = val;
end
end
Post Follow-up to this messageWasn't as hard as I thought .... http://xtargets.com/cms/Tutorials/M...GUI-Tables.html You use the little tool detailed on the website as below function use_table data = rand(4); % Create a uitable with a simple matlab data model. Specify % that the conversion class will be %g. t = xtargets_uitable(4,4, @getfun, @setfun, '%g'); function val = getfun( row, col) val = data(row,col); end function setfun( row, col, val) data(row,col) = val; end end
Post Follow-up to this messagePowered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.