Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
passing value between functions in a GUI

Subject: passing value between functions in a GUI

From: edward

Date: 10 Aug, 2011 17:30:25

Message: 1 of 1

i have a 3Danimation plot posted to a GUI. i initiate the action on the plot via a 'pushbutton' also on the GUI. i have a 'slider' on the GUI where I want to control the speed of refreshing of the plot. i have the following code in the slider function
function slider1_Callback(hObject, eventdata, handles)
slider_value = get(hObject,'Value')
when i click on the 'slider' when the plot is running it will stop for the appropriate duration of time

i am new to matlab and pretty much a dufas and can't figure out how to pass the 'slider_value' into the 'pause' function which resides in the loop for the plot which is included in the 'pushbutton' function on the GUI...below is the portion of the code for the looping of the plot...you can see i have tried (guesed) at just about everything tryint to get the value into the 'pause'...one last thing...when I hard-code' the 'pause' function with a value...it works as expected anticipated
for k=3:length(Y)
    z=t(:,1:k)
    set(h,'Zdata',z)
    drawnow
    %set(eventdata,'slider1_Callback','slider_value')
    %get(slider1_Callback,'eventdata')
    %pause('eventdata')
    set(slider1.hObject,'Callback','pause(slider_value)')

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us