About Site Map Submit Contact Us Log in | Create an account
Create an account Log In
Average Rating
User Rating:
Visitors Rating:
My rating:

Write review
  • Last update: 5 years ago
  • Total downloads: 96
  • Operating system: Linux, Mac OS X, Win All, BSD, Solaris
  • Publisher: Morris Maynard
See full specifications

scripts default iconEditable Table in MATLAB (Scripts) Publisher's description

This provides a table as a separate MATLAB script which can be called from any figure

This provides a table as a separate MATLAB script which can be called from any figure. The table can reside within a figure with other UI controls. The fields can be edited and the table can be scrolled. Numeric or string fields are supported. More than one table per figure should be possible.

You can create a table as follows (just running the script with no arguments does this):

fig = nf;
tbl = axes('units', 'pixels','position', [10 10 400 100]);
cell_data = {...
'Alpha', 1, 2, 3,'';...
'Bravo', 4, 5, 6,'';...
'Charlie', 7, 8, 9,'';...
'Dog', 10,11,12,'';...
'Echo', 13,14,15,'';...
'Golf', 19,20,21,'';...
'Hotel', 26,27,28,'';...

columninfo.titles={'Param','Lower Limit','Upper Limit',...
'Initial Value','Result'};
columninfo.formats = {'%4.6g','%4.6g','%4.6g','%4.6g','%4.6g'};
columninfo.weight = [ 1, 1, 1, 1, 1];
columninfo.multipliers = [ 1, 1, 1, 1, 1];
columninfo.isEditable = [ 1, 1, 1, 1, 0];
columninfo.isNumeric = [ 0, 1, 1, 1, 1];
columninfo.withCheck = true;
columninfo.chkLabel = 'Use';
rowHeight = 16;

mltable(fig, tbl, 'CreateTable', columninfo, rowHeight, cell_data,...

When you click on a cell which is "Editable", the cell changes color. When you click again, the editing cursor appears and you can edit the cell contents. To finish editing, press then Enter key or click on another cell.

If you use the table in a GUI form designed with GUIDE, you probably want to end the editing when you click on another part of the form. To do this, add the following lines after the one which creates the table:

endfcn = sprintf('mltable(%14.13f, %14.13f, ''SetCellValue'');',...

To get the current table contents, use:

info = get(tbl,'UserData');
data = info.data;

The variable "data" now contains a cell array of the table contents.

This describes the "columninfo" structure:
Titles: array of strings to place above each column. Use '' for non-labeled columns.
Weight: array of column widths. Use 1 for unit width, > 1 for wider columns. This does not work for column 1 (bug!)
Multipliers: Use to scale numeric values. For instance, if Multiplier for column 2 is set to .01, then the value displayed in column 2 will always be 1/100 of the value in the data array.
Formats: sprintf style formats for each column. Ignored for non-numerics. Use '%f' if in doubt.
IsEditable: array of 1s and 0s for each column. 0 means column is read-only.
isNumeric: array or 1s and 0s for each column. 1 means treat column as numeric (will do scaling by Multiplier, check for non-numeric input, and will store the value as a number, not a string.)
withCheck: optional field; if set to "true", the table will have a column of checkboxes along the left side.
chkLabel: optional field: if set to a string, this will be placed above the column of checkboxes if there is one.
rowsFixed: the table won't have buttons for insert/delete rows, even if some fields are editable

How to use check boxes:
If use set a field named 'withCheck' in columnInfo to 'true', then the table will have a column of checkboxes along the left hand side. You can set the initial state of the check boxes with code like this:

for ii = 1:numrows
mltable(fig, tbl, 'SetCheck',[],[],[],[],ii, checkval(ii));

assuming that checkval is a vector of 1s and 0s to determine the initial state.
After the figure is created, you can get the state of the checkboxes with code like this:

data = get(tbl, 'UserData');
checkval = data.isChecked;

and now checkval is a vector of 1s and 0s depending on the checkbox states.

How to use DoubleClick

You can have the table call your own routine when the user double clicks on a cell.

mltable(fig, hobj, 'SetDblClick', 'Myfunc', 'fmt_str');

where 'Myfunc' is a string naming the function to call, and 'fmt_str' is a string representing additionial arguments. If you are using the table in a Guide figure, use SetDblClick like this:

mltable(gcf, handles.tbl, 'SetDblClick', [], [], [], [], 'myfig', 'dblClick_Callback');

where 'myfig' is the name of the main figure and dblClick_Callback is a function within that figure's main file.

Your function will be called as

[] = Myfunc(hObject, [], handles, arg1, arg2, ...)

where arg1, arg2, etc are the argument names you passed to SetDblClick in the format string.

(Based on code by a colleague, Greg Gershanok, with his permission.)

System Requirements:

MATLAB 7.0.4 (R14SP2)
Program Release Status: New Release
Program Install Support: Install and Uninstall

Editable Table in MATLAB (Scripts) Tags:

Click on a tag to find related softwares

Is Editable Table in MATLAB (Scripts) your software?

Manage your software

Most Popular

scripts default icon ASK, OOK, FSK, BPSK, QPSK, 8PSK modulation 1.1
ASK, OOK, FSK, BPSK, QPSK, 8PSK modulation contain several functions for digital modulation simulation
scripts default icon Simulink Communication Labs 1.1
Simulink Communication Labs allows you to learn communication systems in greater depth.
scripts default icon M-QAM modulation and demodulation 1.1
M-QAM modulation and demodulation is the QAM modulation and demodulation tech.
scripts default icon LZW Compression/Decompression 1.1
LZW Compression/Decompression - Updated LZW compressor and decompressor with reasonable performance
scripts default icon InSPIRE utility to plot a 2D displacement field (Scripts) 1.0
This program plots the deformation field (displace vectors) contained in vector.txt.