Clicking on List to Plot
Ältere Kommentare anzeigen
BACKGROUND: Below is the solution that Image Analyst(forum member) created by constructing two lists with variables and by clicking on the variable the data is output in the command window (see code below).
GOAL: My next step is to click on one variable on each list, and create a plot from the two variables that I selected.
CODE:
function learnlists
clc;
format compact;
format long;
figure;
yourcell={'mass','velocity','time','acceleration','speed'}
% Create first listbox.
uicontrol('Style', 'listbox','Position',[100 100 200 200],...
'string',yourcell,'Callback',@measurements)
% Create second listbox.
uicontrol('Style', 'listbox','Position',[300 100 200 200],...
'string',yourcell,'Callback',@measurements)
function [out] = measurements(handleToParentControl,evnt)
mass = [ 23 45 44];
velocity = [34 53 32];
time = [1 2 3];
acceleration = [32 22 12];
speed = [12 33 44];
selectedItem = get(handleToParentControl,'value');
% Print selected array to command window:
switch selectedItem
case 1
mass
case 2
velocity
case 3
time
case 4
acceleration
case 5
speed
end
1 Kommentar
Walter Roberson
am 30 Mai 2013
hmmm.. thought you already asked this one a little earlier ?
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu App Building finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!