MATLAB SIMULINK 7 - GRAPHICAL USER INTERFACE Manuel d'utilisateur Page 458

  • Télécharger
  • Ajouter à mon manuel
  • Imprimer
  • Page
    / 500
  • Table des matières
  • MARQUE LIVRES
  • Noté. / 5. Basé sur avis des utilisateurs
Vue de la page 457
14 Examples of UIs Created Programmatically
14-14
View the Example Code
To obtain copies of the program files for this example, follow these steps:
1
Set your current folder to one to which you have write access.
2
Copy the example code and display it in the Editor by issuing the following MATLAB
commands:
copyfile(fullfile(docroot, 'techdoc','creating_guis',...
'examples','tableplot.m')),...
fileattrib('tableplot.m', '+w');
edit tableplot.m
Set Up and Interact with the uitable
This example has one file, tableplot.m, that contains its main function plus two local
functions (uicontrol callbacks). The main tableplot function creates a figure and
populates it with uicontrols and one axes.
The function hides the figure's menu bar because it is not needed.
% Create a figure that will have a uitable, axes and checkboxes
figure('Position', [100, 300, 600, 460],...
'Name', 'TablePlot',... % Title figure
'NumberTitle', 'off',... % Do not show figure number
'MenuBar', 'none'); % Hide standard menu bar menus
The main tableplot function sets up the uitable immediately after loading a data
matrix into the workspace. The table's size adapts to the matrix size (matrices for
uitables must be 1-D or 2-D).
% Load some tabular data (traffic counts from somewhere)
count = load('count.dat');
tablesize = size(count); % This demo data is 24-by-3
% Define parameters for a uitable (col headers are fictional)
colnames = {'Oak Ave', 'Washington St', 'Center St'};
% All column contain numeric data (integers, actually)
colfmt = {'numeric', 'numeric', 'numeric'};
% Disallow editing values (but this can be changed)
coledit = [false false false];
% Set columns all the same width (must be in pixels)
colwdt = {60 60 60};
Vue de la page 457
1 2 ... 453 454 455 456 457 458 459 460 461 462 463 ... 499 500

Commentaires sur ces manuels

Pas de commentaire