Wednesday, April 10, 2013

Belajar scrollbar di MATLAB



function test_scrollbar
f = figure('menubar' , 'none');
panel = uipanel('units', 'pix', 'position', [40,40, 400,400]);
axes('units', 'pix', 'position', [0,0,400,400], 'parent', panel);
line([-10,10],[0,0]);
line([0 0],[-10,10]);
my_slider = uicontrol('units', 'pix', ...
'style', 'slider', ...
'position', [40,10, 100,20]);
while ishandle(f)==1
s = get(my_slider, 'value');
c = asind(s);
l = line([-10,10], [-10*tand(c) 10*tand(c)], 'Color', 'g');
m = line([10*tand(c) -10*tand(c)], [-10,10], 'Color', 'g');
drawnow;
if ishandle(l)==1, delete(l);end
if ishandle(m)==1, delete(m);end
end
end