How to use MATLAB GUI uitable

Creation and setting of uitable

Table Property Editor Set uitable

2. MATLAB code to set uitable

Creation and setting of uitable

Table Property Editor Set uitable

  • Create a uitable and set its Tag to Tab1 (in Property Inspector)
  • Table Property Editor->Set column title, column width (100), and set column to editable state
  • Table Property Editor ->Set row title (A….E)
  • Initialize the data of uitable and generate magic(5) matrix in ws for data initialization
  • Demonstrates the striping effect of uitable's background color (Backgroundcolor)

    Creation and setting of uitable

    MATLAB code setting uitable

  • Create a uitable and set its Tag to Tab2 (in Property Inspector)
  • Set column title, column width (100), set column to editable state
    set thob jeet,'Columrurame', sub-column number 1', 'column number 2', 'column number', column number 4', 'column No. 5'})
    set (hobject, 'ColumnWidth', (100, 100, 100, 100, 100, 100])
    set (hob ject, ' ColumrEdit able', 1ogical (ones (1,5)))
  • Set row title (A ..E)
    set thob ject,' Rovame'',I &','B','C','D','E'})
  • Initialize the data set of uitable
    (hob ject, " Dzta', mzgic (5))
  • Set the striping effect of the uitable's background color (Backgroundcolor)
    set (hObject, 'BackgroundColor', [1 0 0:0 1 0])

Creation and setting of uitable

Create 2 x 5 uitable

  • Create a uitable and set its Tag to Tab3 (in Property Inspector)
  • Table Property Editor->Insert column and set column title
  • Table Property Editor -Set row headers, delete redundant rows
  • Table Property Editor-Initialize uitable data

Creation and setting of uitable

Create uitables of multiple data types

  • Create a uitable and set its Tag to Tab4 (in Property Inspector)
  • Table Property Editor -> Set column title, column width (100), and set column to editable state
  • Table Property Editor ->Set column data type; set row title (default numeric sequence)
  • Set the striping effect of the uitable's background color (Backgroundcolor)
  • MATLAB code sets the data set of uitable
    (object,'Data',1 big-headed son','male',6,1ogicz1 (0):..
    'small-headed dad','male',32,1ogica1 (1) :...
    , apron mother',, female:, 30, 1ogical c0): 1)
  • Set the font size (Fontsize) of uitable to 10

Application examples of uitable

Problem description: The product weight requirement for the barreled laundry detergent produced by a certain factory is ±0.05Kg. The quality inspection department is now conducting a sampling inspection on a batch of products. Three different surveyors weighed 5 barrels of laundry detergent respectively. The weighing results can be found in the exame.xlsx file. Please display the weighing results in a uitable and draw a graph of the weighing results.

Application examples of uitable

  • Create a new GUI, create a uitable, and set its Tag to Tab4 (in Property Inspector)
  • Table Property Editor->Set column title, column width (100), and set the column to non-editable state
  • Table Property Editor ->Set row title (default numeric sequence)
  • Create a PushButton and modify its String to "Import measurement data"
  • In the callback function of PushButton, read the measurement data and display it in the uitable

Ifilename, PathmameJ=uigetfile(T*.x13x':'*.×12'sub,'read test data file>:

[nun, txt, raw]=xlsread ([pathname, filename]) set (handles. Tab4, 'Data', nun (:, 2: end))

  • Create a uitable again and set its Tag to Tab5
  • Table Property Editor->Set column title, column width (100), and set the column to editable state
  • Table Property Editor ->Set the row title to "Not a row title»
  • MATLAB code sets the data set of Tab5
    (hobject, 'Data', [2. 95, 0. 01, 3. 05])

Application examples of uitable

-Create a PushButton again and modify its String to "draw measurement data"

  • Create an ax control for displaying measurement data graphics
  • In the two callback numbers of PushButton, draw the measurement data and add the upper and lower limits of the weight.

TestDat a-get (handles. Tab4, 'Data')

Limits=get (handles. Tab5, 'Data') axes (handles. axes 1) plot (1:5, TestData, 'Marker',' o') hold on

plot ([1, 51,ILinit(1),Linits (1)1,’r--','Linevidth', 2)plot ([1,51, ILinits (3), Limit s (3)1,’z--',“Linevidth',2)

set (gca,' TTick', ILinits (1):Linits (2) :Linit s (3])

1egend(fSurveyor A", Surveyor B', 'Surveyor C', 'Upper weight limit', 'Lower weight limit' 1, 'Location', NorthEastout side')

hold off

-Set different upper and lower limit values ​​to view the drawing effect

Version:0.9 StartHTML:0000000105 EndHTML:0000000594 StartFragment:0000000141 EndFragment:0000000554

Application examples of uitable

Guess you like

Origin blog.csdn.net/zuoan1993/article/details/132742804