Clear Filters
Clear Filters

Pass a vector into GUI Slider

3 views (last 30 days)
Karthik Brs
Karthik Brs on 16 Nov 2015
Hello everyone! I am required to insert a Slider into my quiver plot(plot of vector field). The slider basically quantifies a vector 'rpm' with the min. and max. values of RPM as labelled on the slider. I am including my code if you guys are interested in giving it a try!
rpm = [1000 900 800];
range = 0:0.1:2*pi;
minrpm = min(rpm);
maxrpm = max(rpm);
y = [0 0 0];
Fy =[1 .5 1]; %Amplitudes of a test vector
yy = [92 90 150]; %Phase angle of test vector
alpha_y = degtorad(yy);
x = [0 0 0];
Fx = [.8 .7 1.1]; %Amplitudes of a test vector
xx = [90 100 80]; %Phase angle of test vector
alpha_x = degtorad(xx);
hFig = figure; % to define Figure Properties
set(hFig, 'Position', [0 0 1000 1000]);
for e = 1:length(range);
q = quiver(x, y, Fx.*cos(alpha_x+range(e)), Fy.*cos(alpha_y+range(e)),1,'LineWidth',2);
axis([-1.1 1.1 -1.1 1.1]);
M(e) = getframe;
sld = uicontrol(hFig,'Style','slider','Min',min(rpm),'Max',max(rpm),'Value',900,'Position', [81,54,419,23]);
bl1 = uicontrol('Parent',hFig,'Style','text','Position',[50,54,23,23],'String',minrpm);
bl2 = uicontrol('Parent',hFig,'Style','text','Position',[500,54,23,23],'String',maxrpm);
bl3 = uicontrol('Parent',hFig,'Style','text','Position',[240,25,100,23],'String','RPM');% Center and Size of Window
end
The vector 'x','y' and 'rpm' are all of same lenghts. I am required to display the quiver plot with a 'rpm' slider such that the vector field produced by the command 'quiver' changes as I change the slider. Therefore, according to my example, there are 3 vectors of each(Fx.*cos(alpha_x)and Fy.*cos(alpha_y)) and there 3 rpm's. If the move the slider, the vector fields should also change. The first element in 'rpm' corresponds to the 1st vector of Fx.. and Fy.., second element in 'rpm' vector corresponds to 2nd vector in Fx.. and Fy..
Thank you in advance!

Answers (0)

Categories

Find more on Vector Fields 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!