Version (617 KB) by Robert
MATLAB interactive function caller
Updated 5 Jul 2016

Creates a slider useful for exploring your custom function behavior. Attach your function inputs to sliders using manipulate.m and "play-around" with the values to see your function's response. This is especially useful for interactive plotting.

Help text:

calls the function func(ARGS) and allows the user to control the
values of the arguments via sliders. If DEFAULT is not set, the value
is initially set to ARG_MIN.

manipulate expects one cell input per argument. All arguments must be
scalars. Cells can also be of the form{LABEL,VALUES,[DEFAULT]} where
VALUES is a 1D array containing allowed values of the argument.

H = manipulate(...) returns the the slider handles.

manipulate(...,'UpdateMode',MODE) allows the user to set the frequency
with which the function is called.
'Low' Refresh only when slider is released (after drag) or
clicked, or when edit field is altered.
'High' Also refresh continuously as slider is dragged. [Default]
'Manual' Refresh only when user presses button.

manipulate(...,'SliderStep',[SMALL BIG]) allows the user to set the
step size of incremental slider increases and decreases. See UICONTROL
for details.

x = 1:.001:10;
gca, L = plot(1,1,1,1);
myfunc = @(i,f,theta)set(L(i),'XData',x,'YData',sin(10*x)+sin(f*x+theta));

Plots the interference of two sine waves and allows the user to
manipulate the frequency and phase offset of the second wave. Then does
the same again, adding the slider controls to the existing slider

x = linspace(-10,10,1e4);
fig = figure('Visible','off');
ax = [subplot(2,1,1),subplot(2,1,2)];
f1 = @(u,s) plot(ax(1),x,exp(-1/2*((x-u)/s).^2)/sqrt(2*pi)/s,'r');
f2 = @(u,s) title(ax(1),sprintf('N(%.2f,%.2f)',u,s^2));
f3 = @(u,s) plot(ax(2),x,erf((x-u)/s/sqrt(2))/2+1/2,'r');
myfunc = @(u,s) {f1(u,s),f2(u,s),f3(u,s)};
manipulate(fig,myfunc,{'Mean',-5,5,0},{'Standard Deviation',.01,5,1})
linkaxes(ax,'x'), set(ax,'NextPlot','replacechildren')

Plots the normal distribution and its cumuliative distribution on
separate subplots and allows the user to manipulate the mean and
standard deviation. The mean is initially set to 0 and the standard
deviation to 1. The slider controls appear in the same figure as the

Created by:
Robert Perrotta

Cite As

Robert (2024). manipulate (, GitHub. Retrieved .

MATLAB Release Compatibility
Created with R2013a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Find more on Migrate GUIDE Apps in Help Center and MATLAB Answers

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Versions that use the GitHub default branch cannot be downloaded

Version Published Release Notes

Removed github username from submission title.

Updated description (again).

Updated the description

Added an image

To view or report issues in this GitHub add-on, visit the GitHub Repository.
To view or report issues in this GitHub add-on, visit the GitHub Repository.