How can get data from popup menu and launch the function with pushbutton?
Mostra commenti meno recenti
Hi everybody,
I got homework about calculating velocity of object at earth and mars,jupiter etc. respect to the gravity.So i have to choose world from popup menu and calculate velocity when hit pushbutton.
here my code i wrote.I cant get gravity value from popup menu.I tried lots of thing but always got error msg.
function hwork
ScreenSize = get(0,'ScreenSize'); % getcurrent screen size: [left, bottom, width, height] set(gcf,'doublebuffer','on','clipping','off','color','w','name','menubar','none', ... 'resize','off','numbertitle','off','Units','Pixels',... 'Position' ,[(ScreenSize(3)/2 - 500) (ScreenSize(4)/2 - 400) 1000 800]);
%popup menu uicontrol('Style', 'popup',... 'String', 'dunya|ay',... 'Position', [150 730 100 50],... 'Callback', @gravitty)
%run buttonu
uicontrol('Style', 'pushbutton', 'String', 'calistir',...
'Position', [260 755 100 25],...
'Callback', @run);
end
function gravitty( handles)
switch get(handles.yercekimi,'Value')
case 1
set (handles.run,'gravity',9.8);
case 2
set (handles.run,'gravity',24);
otherwise
end
end
function run (ball,box)
t = 0:0.05:3; v_box = 2; y_box = 0.5 gravity t.^2; y_ball = max(y_ball) - y_ball; x_ball = 10; y_box = 0; x_box = v_box .* t;
end
thanks
Risposte (0)
Categorie
Scopri di più su Graphics Objects in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!