Placing a slider control on a surf plot?
Show older comments
Is there a way to implement a slider-type control for a 3D surf plot? I've looked into uicontrol but it apparently only works for plots created with figure.
Is there a different way of implementing this? The control doesn't have to be a slider; I want something that will enable the user to input a frequency value within 20Hz-20kHz, which then goes through a section of code that does the math with this value and updates the surf plot accordingly.
Sample code that I want to put a slider on is below. Attempting to use uicontrol gives me the error: surface cannot be a parent.
% Plotting a sphere who's radius changes based on slider position on plot
% Defining theta, phi and r for spherical coordinates
theta = linspace(-pi,pi,73);
theta = repmat(theta,37,1);
theta(:,1) = -1.*theta(:,1); % not necessary but it connects the last set of points with the first to give a smooth surface
phi = linspace(-pi/2,pi/2,37)';
phi = repmat(phi,1,73);
r = user_input*ones(size(theta)); % user_input comes from the slider that changes the radius of plotted sphere
[x,y,z] = sph2cart(theta,phi,r);
surf(x,y,z)
Accepted Answer
More Answers (0)
Categories
Find more on Migrate GUIDE Apps in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!