0 valutazioniIl 0% ha trovato utile questo documento (0 voti)
133 visualizzazioni5 pagine
The document describes the uitable component in MATLAB, which creates a 2D graphical table. It provides the syntax to create a uitable, including optional properties. Users can edit table cells if the ColumnEditable property is set to true. The document includes examples that demonstrate how to create uitables with different data types, set column properties like names and formats, and specify the table parent and position.
The document describes the uitable component in MATLAB, which creates a 2D graphical table. It provides the syntax to create a uitable, including optional properties. Users can edit table cells if the ColumnEditable property is set to true. The document includes examples that demonstrate how to create uitables with different data types, set column properties like names and formats, and specify the table parent and position.
The document describes the uitable component in MATLAB, which creates a 2D graphical table. It provides the syntax to create a uitable, including optional properties. Users can edit table cells if the ColumnEditable property is set to true. The document includes examples that demonstrate how to create uitables with different data types, set column properties like names and formats, and specify the table parent and position.
Syntax uitable uitable('PropertyName1', value1,'PropertyName2',value2,...) uitable(parent,...) handle = uitable(...) Description uitable creates a 1-by-1 uitable object in the current figure window, using default property values. If no figure exists, a new figure window opens. uitable('PropertyName1', value1,'PropertyName2',value2,...) creates a uitable object with specified property values. Properties that you do not specify assume the default property values. See the Uitable Properties reference page for information about the available properties. uitable(parent,...) creates a uitable object as a child of the specified parent handle parent. The parent can be a figure or uipanel handle. If you also specify a different value for the Parent property, the value of the Parent property takes precedence. handle = uitable(...) creates a uitable object and returns its handle. After creating a uitable object, you can set and query its property values using the set and get functions. Remarks Users can change values in a table if the ColumnEditable property is true for the column they attempt to edit. By default, this property is false for all columns. If the column contains pop-up choices, only the current choice is visible (and not the pop-up menu control) when its column cannot be edited. After editing a value, the edited value is displayed and the CellEditCallback fires when the user does any of the following: Types Enter Clicks another table cell Clicks anywhere else within the table Clicks another control or area within the same figure window However, the CellEditCallback does not fire if the user edits a cell and clicks in another figure window or desktop tool. If the user then returns to the table to edit a different cell, the previous CellEditCallback still does not fire. Even though the table displays the results of the previous edit, the underlying data matrix (the table's Data property) is not updated to contain the value that appears in the cell. Note If you attempt to create a uitable when running MATLAB on a Linux system without a Java virtual machine (matlab -nojvm) or without a display (matlab nodisplay), no table generates and you receive an error. Examples Example 1 This example creates a table in the current figure. If no figure exists, one is created. t = uitable;
As the table has no content (its Data property is empty), it initially displays no rows or columns. Provide data (a magic square), and set column widths to 25 pixels uniformly to make the entire table visible. set(t,'Data',magic(10)) set(t,'ColumnWidth',{25})
The uitable ColumnWidth property is specified as a cell array. It can contain: One number (a width measured in pixels) or the string 'auto' A cell array containing a list of pixel sizes having up to as many entries as the table has columns If a list has n entries, where n is smaller than the number of columns, it sets the first n column widths only. You can substitute 'auto' for any value in the cell array to have the width of that column calculated automatically. Example 2 This example creates a table with a 3-by-3 data matrix. This example specifies the column names, parent, and position of the table: f = figure('Position',[100 100 300 150]); dat = rand(3); cnames = {'X-Data','Y-Data','Z-Data'}; t = uitable('Data',dat,'ColumnName',cnames,... 'Parent',f,'Position',[20 20 250 100]);
Example 3 This example creates a table with a 3-by-4 array that contains numeric, logical, and string data in the following columns: First column (Rate): Numeric, with three decimals (not editable) Second column (Amount): Currency (not editable) Third column (Available): Check box (editable) Fourth column (Fixed/Adj): Pop-up menu with two choices: Fixed and Adjustable (editable) f = figure('Position',[100 100 400 150]); dat = {6.125, 456.3457, true, 'Fixed';... 6.75, 510.2342, false, 'Adjustable';... 7, 658.2, false, 'Fixed';}; columnname = {'Rate', 'Amount', 'Available', 'Fixed/Adj'}; columnformat = {'numeric', 'bank', [], {'Fixed' 'Adjustable'}}; columneditable = [false false true true]; t = uitable('Units','normalized','Position',... [0.1 0.1 0.9 0.9], 'Data', dat,... 'ColumnName', columnname,... 'ColumnFormat', columnformat,... 'ColumnEditable', columneditable);
For more information about working with uitables, see the following examples in the MATLAB Creating Graphical User Interfaces documentation: