From: matt dash on
"muzaffar " <muzaffarbashir(a)yahoo.com> wrote in message
<fvpqvc$3ue$1(a)fred.mathworks.com>...
> hi everybody
> could some one please tell me why i am unable to get
> values for
> variable outdd? in the following program.
> i can get and plot scroll wheel up/down movement with time
> let say but i am unable to get array values in the end.
> plz use hold on at command line after calling to the
> function below.
>
>
> function outdd= scroll_wheel12()
> % Illustrates how to use WindowScrollWheelFcn property
> %f = %e 'WindowScrollWheelFcn'
> global dd
> set(gcf,'WindowScrollWheelFcn',@figScroll);
>
>
> x = [0:.1:40];
> y = 4.*cos(x)./(x+2);
> a = axes;
> h = plot(x,y);
>
> title('Rotate the scroll wheel')
> var12=0;
> tv12=1;
> function figScroll(src,evnt)
>
> if evnt.VerticalScrollCount > 0
> var12=var12+1;
> tt(tv12)=tv12;
> xv12(tv12)=var12;
>
> elseif evnt.VerticalScrollCount < 0
> var12=var12-1;
> tt(tv12)=tv12;
> xv12(tv12)=var12;
>
> end
>
> disp('time')
> disp(tv12)
> disp('value')
> disp(var12)
> %outdd=[tv12 var12];
> dd=[tt; xv12];
> plot(tt,xv12,'*')
> tv12=tv12+1;
>
> end %figScroll
> % disp(eventdata.scrdata)
>
> disp(var12)
> % outdd=[tv12 var12];
> outdd=dd;
>
> end % scroll_wheel
>


The problem is that the line "outdd=dd" runs as soon as you
run the main function, and does not wait for the user to
scroll the wheel. Try instead adding a similar line to the
figScroll function, since this is what runs when the user
moves the mouse wheel. (You will need to figure out how to
get the value back to the command window or wherever you
want it though... how you do that depends on when/where you
want to access this value)