Slider for data generated in a for loop

5 visualizaciones (últimos 30 días)
Karthik Brs
Karthik Brs el 17 de Nov. de 2015
Hello Everyone! I am plotting the vector fields of reaction forces using the 'quiver' command. I want the vector fields to change as I change the Slider. The slider should represent the vector 'rpm' which contains 3 values. Therefore, the code results in 3 vector fields for 3 rpm values. I have used 'for' loop for this purpose. I am including my code with this query. I wish to display the plot with the slider such that, when the slider is changed, it should plot the corresponding 'for' loop increment for 'ii'. Thank you advance!
My code:
rpm = [1000 900 800];
range = 0:0.1:2*pi;
minrpm = min(rpm);
maxrpm = max(rpm);
y = [-0.1 -0.9 0.97];
Fy =[1 .5 1];
yy = [92 10 150];
alpha_y = degtorad(yy);
x = [0.16 0.4 -0.56];
Fx = [.8 .7 1.1];
xx = [90 15 80];
alpha_x = degtorad(xx);
hFig = figure; % to define Figure Properties
set(hFig, 'Position', [0 0 1000 1000]);
n = 0;
for ii=1:numel(rpm)
n=n+1;
for e = 1:length(range);
q = quiver(x(ii), y(ii), Fx(ii).*cos(alpha_x(ii)+range(e)), Fy(ii).*cos(alpha_y(ii)+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
end

Respuestas (0)

Categorías

Más información sobre Graphics Objects en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by