function varargout = randomwalk(varargin) % RANDOMWALK M-file for randomwalk.fig % Copyright by Boris Baeumer, University of Otago, 2007 % bbaeumer@maths.otago.ac.nz % visualises particles making random jumps at random times to help % understanding of scaling limits. % If you have any questions about its usage, don't hesitate to contact % me. % RANDOMWALK, by itself, creates a new RANDOMWALK or raises the existing % singleton*. % % H = RANDOMWALK returns the handle to a new RANDOMWALK or the handle to % the existing singleton*. % % RANDOMWALK('CALLBACK',hObject,eventData,handles,...) calls the local % function named CALLBACK in RANDOMWALK.M with the given input arguments. % % RANDOMWALK('Property','Value',...) creates a new RANDOMWALK or raises the % existing singleton*. Starting from the left, property value pairs are % applied to the GUI before randomwalk_OpeningFunction gets called. An % unrecognized property name or invalid value makes property application % stop. All inputs are passed to randomwalk_OpeningFcn via varargin. % % *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one % instance to run (singleton)". % % See also: GUIDE, GUIDATA, GUIHANDLES % Copyright 2002-2003 The MathWorks, Inc. % Edit the above text to modify the response to help randomwalk % Last Modified by GUIDE v2.5 25-Jun-2007 21:28:51 % Begin initialization code - DO NOT EDIT gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @randomwalk_OpeningFcn, ... 'gui_OutputFcn', @randomwalk_OutputFcn, ... 'gui_LayoutFcn', [] , ... 'gui_Callback', []); if nargin && ischar(varargin{1}) gui_State.gui_Callback = str2func(varargin{1}); end if nargout [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); else gui_mainfcn(gui_State, varargin{:}); end % End initialization code - DO NOT EDIT % --- Executes just before randomwalk is made visible. function randomwalk_OpeningFcn(hObject, eventdata, handles, varargin) % This function has no output args, see OutputFcn. % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % varargin command line arguments to randomwalk (see VARARGIN) scrsize=get(0,'ScreenSize'); scrsize(2)=scrsize(4)*.04; scrsize(4)=scrsize(4).*.92; set(handles.figure1,'Position',scrsize); handles.vlowxlim=0; handles.vlowylim=0; handles.vupxlim=100; handles.vupylim=100; handles.exp=1; handles.run=0; handles.xfun=1; handles.yfun=1; handles.powx=1; handles.powy=1; handles.waitfun=1; handles.F=[]; handles.moviename='randomwalkmovie'; plotdensity(handles); set(handles.axes3,'ButtonDownFcn','randomwalk(''axes3_ButtonDownFcn'',gcbo,[],guidata(gcbo))'); handles.part=4000; handles.om=0; handles.pos=zeros(4000,2); handles.time=zeros(4000,1); handles.realtime=0; handles.shift=0; plot(handles.axes1,0,0,'.'); xlim(handles.axes1,[0,100]); ylim(handles.axes1,[0,100]); plot(handles.axes2,0,0,'.'); % Choose default command line output for randomwalk handles.output = hObject; % Update handles structure guidata(hObject, handles); % UIWAIT makes randomwalk wait for user response (see UIRESUME) % uiwait(handles.figure1); % --- Outputs from this function are returned to the command line. function varargout = randomwalk_OutputFcn(hObject, eventdata, handles) % varargout cell array for returning output args (see VARARGOUT); % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Get default command line output from handles structure varargout{1} = handles.output; % --- Executes on selection change in xjumps. function xjumps_Callback(hObject, eventdata, handles) % hObject handle to xjumps (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: contents = get(hObject,'String') returns xjumps contents as cell array % contents{get(hObject,'Value')} returns selected item from xjumps handles.xfun=get(hObject,'Value'); plotdensity(handles); guidata(hObject,handles); function r=density(y,xfun,ex,pow) %returns densityvalue depending on which density was selcted by xfun x=(y>0).*y.^(1./pow.*ex)+(y<0).*y.^ex; switch xfun case 1 r=1/4*(sign(x)+1).*(sign(1-x)+1); case 2 r=1/20*(sign(x)+1).*(sign(5-x)+1); case 3 r=1/4*(sign(x+1/2)+1).*(sign(1/2-x)+1); case 4 r=exp(-x).*(sign(x)+1)/2; case 5 r=1/5*exp(-1/5*x).*(sign(x)+1)/2; end r=r.*(y>0).*y.^(1./pow.*ex-1).*1./pow+r.*(y<0).*y.^(ex-1); function plotdensity(handles) xfun=handles.xfun; yfun=handles.yfun; if handles.exp<0 & (handles.xfun==3 | handles.yfun==3) [X,Y]=meshgrid(-5:.25001:5); else [X,Y]=meshgrid(-1:.201:8); end axes(handles.axes3); mesh(X,Y,density(X,xfun,handles.exp,handles.powx).*density(Y,yfun,handles.exp,handles.powy)); set(handles.axes3,'ButtonDownFcn','randomwalk(''axes3_ButtonDownFcn'',gcbo,[],guidata(gcbo))'); % --- Executes during object creation, after setting all properties. function xjumps_CreateFcn(hObject, eventdata, handles) % hObject handle to xjumps (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: popupmenu controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc set(hObject,'BackgroundColor','white'); else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end % --- Executes on selection change in yjumps. function yjumps_Callback(hObject, eventdata, handles) % hObject handle to yjumps (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: contents = get(hObject,'String') returns yjumps contents as cell array % contents{get(hObject,'Value')} returns selected item from yjumps handles.yfun=get(hObject,'Value'); plotdensity(handles); guidata(hObject,handles); % --- Executes during object creation, after setting all properties. function yjumps_CreateFcn(hObject, eventdata, handles) % hObject handle to yjumps (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: popupmenu controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc set(hObject,'BackgroundColor','white'); else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end % --- Executes on button press in stop. function stop_Callback(hObject, eventdata, handles) % hObject handle to stop (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) handles.run=0; guidata(hObject,handles); if length(handles.F)>0, movie2avi(handles.F,handles.moviename,'fps',5,... 'compression','Cinepak'); handles.F=[]; end guidata(hObject,handles); % --- Executes on button press in go. function go_Callback(hObject, eventdata, handles) % hObject handle to go (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) handles.run=1; guidata(hObject,handles); part=handles.part; while handles.run==1 omit=handles.om; handles.realtime =handles.realtime +1; movind= (handles.time<=handles.realtime); movingparticles=sum(movind); handles.time(movind)=waitfun(handles.waitfun,handles.time(movind)); if handles.realtime>1 handles.pos(movind,:)=handles.pos(movind,:)+[step(handles.xfun,movingparticles,handles.shift,handles.powx),... step(handles.yfun,movingparticles,handles.shift,handles.powy)].^handles.exp; posx=sort(handles.pos(:,1)); maxx=posx(part-omit); minx=posx(omit+1); posy=sort(handles.pos(:,2)); maxy=posy(part-omit); miny=posy(omit+1); axes(handles.axes1); plot(handles.pos(:,1),handles.pos(:,2),'.'); line([minx,maxx,maxx,minx,minx],... [miny,miny,maxy,maxy,miny],... 'Color','r','Linewidth',2); xlim([handles.vlowxlim,handles.vupxlim]); ylim([handles.vlowylim,handles.vupylim]); hold on m=mean(handles.pos); plot(m(1),m(2),'dr','MarkerSize',6,'MarkerFaceColor','r'); med=median(handles.pos); plot(med(1),med(2),'or','MarkerSize',6,'MarkerFaceColor','y'); hold off axes(handles.axes2); plot(handles.pos(:,1),handles.pos(:,2),'.'); hold on m=mean(handles.pos); meanhandle=plot(m(1),m(2),'dr','MarkerSize',6,'MarkerFaceColor','r'); med=median(handles.pos); medianhandle=plot(med(1),med(2),'or','MarkerSize',6,'MarkerFaceColor','y'); legend([meanhandle;medianhandle],['mean ';'median'],'Location','SO','Orientation','horizontal'); %legend(medianhandle,'median','Location','SO'); line([minx,maxx,maxx,minx,minx],... [miny,miny,maxy,maxy,miny],... 'Color','r','Linewidth',4); xlim([minx,maxx]); ylim([miny,maxy]); % [X,Y]=meshgrid(linspace(minx,maxx,50),linspace(miny,maxy,50)); % Xdif=exp(-(ones(part,1)*linspace(minx,maxx,50)-pos(:,1)*ones(1,50)).^2/(10*i^(4/3)));%/sqrt(pi*i); % Ydif=exp(-(ones(part,1)*linspace(miny,maxy,50)-pos(:,2)*ones(1,50)).^2/(10*i^(4/3)));%/sqrt(pi*i); % Z=(Xdif'*Ydif)'; % subplot 212 % contourf(X,Y,Z,8) end guidata(hObject,handles); drawnow hold off handles=guidata(hObject); if length(handles.F)>0, handles.F(end+1)=getframe(gcf); end %handles.F(end+1) = getframe(gcf); %handles.mov = addframe(handles.mov,F); guidata(hObject,handles); end % --- Executes on button press in reset. function reset_Callback(hObject, eventdata, handles) % hObject handle to reset (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) handles.pos=zeros(handles.part,2); handles.time=zeros(handles.part,1); handles.realtime=0; handles.run=0; axes(handles.axes1); cla; plot(0,0,'.'); xlim([handles.vlowxlim,handles.vupxlim]); ylim([handles.vlowylim,handles.vupylim]); axes(handles.axes2); cla; plot(0,0,'.'); guidata(hObject, handles); function particles_Callback(hObject, eventdata, handles) % hObject handle to particles (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of particles as text % str2double(get(hObject,'String')) returns contents of particles as a double x=str2double(get(hObject,'String')); if isfloat(x)&isfinite(x) handles.part=x; handles.pos=zeros(x,2); handles.time=zeros(x,1); handles.realtime=0; guidata(hObject, handles); else set(hObject,'String',num2str(handles.part)); end % --- Executes during object creation, after setting all properties. function particles_CreateFcn(hObject, eventdata, handles) % hObject handle to particles (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc set(hObject,'BackgroundColor','white'); else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end function omit_Callback(hObject, eventdata, handles) % hObject handle to omit (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of omit as text % str2double(get(hObject,'String')) returns contents of omit as a double x=str2double(get(hObject,'String')); if isfloat(x)&isfinite(x) handles.om=x; guidata(hObject, handles); else set(hObject,'String',num2str(handles.om)); end % --- Executes during object creation, after setting all properties. function omit_CreateFcn(hObject, eventdata, handles) % hObject handle to omit (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc set(hObject,'BackgroundColor','white'); else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end function upxlim_Callback(hObject, eventdata, handles) % hObject handle to upxlim (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of upxlim as text % str2double(get(hObject,'String')) returns contents of upxlim as a double x=str2double(get(hObject,'String')); if isfloat(x)&isfinite(x) handles.vupxlim=x; axes(handles.axes1); xlim(handles.axes1,[handles.vlowxlim,x]); guidata(hObject, handles); else set(hObject,'String',num2str(handles.vupxlim)); end % --- Executes during object creation, after setting all properties. function upxlim_CreateFcn(hObject, eventdata, handles) % hObject handle to upxlim (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc set(hObject,'BackgroundColor','white'); else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end function upylim_Callback(hObject, eventdata, handles) % hObject handle to upylim (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of upylim as text % str2double(get(hObject,'String')) returns contents of upylim as a double y=str2double(get(hObject,'String')); if isfloat(y)&isfinite(y) handles.vupylim=y; axes(handles.axes1); ylim(handles.axes1,[handles.vlowylim,y]); guidata(hObject, handles); else set(hObject,'String',num2str(handles.vupylim)); end % --- Executes during object creation, after setting all properties. function upylim_CreateFcn(hObject, eventdata, handles) % hObject handle to upylim (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc set(hObject,'BackgroundColor','white'); else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end function lowylim_Callback(hObject, eventdata, handles) % hObject handle to lowylim (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of lowylim as text % str2double(get(hObject,'String')) returns contents of lowylim as a double y=str2double(get(hObject,'String')); if isfloat(y)&isfinite(y) handles.vlowylim=y; axes(handles.axes1); ylim(handles.axes1,[y,handles.upylim]); guidata(hObject, handles); else set(hObject,'String',num2str(handles.vlowylim)); end % --- Executes during object creation, after setting all properties. function lowylim_CreateFcn(hObject, eventdata, handles) % hObject handle to lowylim (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc set(hObject,'BackgroundColor','white'); else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end function lowxlim_Callback(hObject, eventdata, handles) % hObject handle to lowxlim (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of lowxlim as text % str2double(get(hObject,'String')) returns contents of lowxlim as a double x=str2double(get(hObject,'String')); if isfloat(x)&isfinite(x) handles.vlowxlim=x; axes(handles.axes1); xlim(handles.axes1,[x,handles.vupxlim]); guidata(hObject, handles); else set(hObject,'String',num2str(handles.vlowxlim)); end % --- Executes during object creation, after setting all properties. function lowxlim_CreateFcn(hObject, eventdata, handles) % hObject handle to lowxlim (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc set(hObject,'BackgroundColor','white'); else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end % --- Executes on button press in invert. function invert_Callback(hObject, eventdata, handles) % hObject handle to invert (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) handles.exp=handles.exp*-1; if handles.exp<0 set(handles.invert,'ForeGroundColor','r'); set(handles.invert,'BackGroundColor','b','String','1/jumps'); set(handles.xjumps,'String',['1/Uniform [0,1] ';'1/Uniform [0,5] ';'1/Uniform [-1/2,1/2]';'1/Exponential a=1 ';'1/Exponential a=5 ']); set(handles.yjumps,'String',['1/Uniform [0,1] ';'1/Uniform [0,5] ';'1/Uniform [-1/2,1/2]';'1/Exponential a=1 ';'1/Exponential a=5 ']); else set(handles.invert,'BackGroundColor','default','ForeGroundColor','default','String','jumps'); set(handles.xjumps,'String',['Uniform [0,1] ';'Uniform [0,5] ';'Uniform [-1/2,1/2]';'Exponential a=1 ';'Exponential a=5 ']); set(handles.yjumps,'String',['Uniform [0,1] ';'Uniform [0,5] ';'Uniform [-1/2,1/2]';'Exponential a=1 ';'Exponential a=5 ']); handles.shift=0; end plotdensity(handles); guidata(hObject,handles); % --- If Enable == 'on', executes on mouse press in 5 pixel border. % --- Otherwise, executes on mouse press in 5 pixel border or over particles. function particles_ButtonDownFcn(hObject, eventdata, handles) % hObject handle to particles (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) handles.run=0; guidata(hObject,handles); % --- Executes on key press over omit with no controls selected. function omit_KeyPressFcn(hObject, eventdata, handles) % hObject handle to omit (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) handles.run=0; guidata(hObject,handles); % --- Executes on key press over particles with no controls selected. function particles_KeyPressFcn(hObject, eventdata, handles) % hObject handle to particles (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) handles.run=0; guidata(hObject,handles); % --- Executes on key press over upxlim with no controls selected. function upxlim_KeyPressFcn(hObject, eventdata, handles) % hObject handle to upxlim (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) handles.run=0; guidata(hObject,handles); % --- Executes on key press over lowxlim with no controls selected. function lowxlim_KeyPressFcn(hObject, eventdata, handles) % hObject handle to lowxlim (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) handles.run=0; guidata(hObject,handles); % --- Executes on key press over lowylim with no controls selected. function lowylim_KeyPressFcn(hObject, eventdata, handles) % hObject handle to lowylim (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) handles.run=0; guidata(hObject,handles); % --- Executes on key press over upylim with no controls selected. function upylim_KeyPressFcn(hObject, eventdata, handles) % hObject handle to upylim (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) handles.run=0; guidata(hObject,handles); % --- If Enable == 'on', executes on mouse press in 5 pixel border. % --- Otherwise, executes on mouse press in 5 pixel border or over xjumps. function xjumps_ButtonDownFcn(hObject, eventdata, handles) % hObject handle to xjumps (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) handles.run=0; guidata(hObject,handles); % --- If Enable == 'on', executes on mouse press in 5 pixel border. % --- Otherwise, executes on mouse press in 5 pixel border or over yjumps. function yjumps_ButtonDownFcn(hObject, eventdata, handles) % hObject handle to yjumps (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) handles.run=0; guidata(hObject,handles); function s=step(v,n,shift,pow) % returns steps according to selection in xjumps/yjumps switch v case 1 s=rand(n,1)+shift; case 2 s=5*rand(n,1)+shift; case 3 s=rand(n,1)-.5; case 4 s=-log(rand(n,1)+shift); case 5 s=-5*log(rand(n,1)+shift); end s=s.^pow; % --- Executes on mouse press over axes background. function axes3_ButtonDownFcn(hObject, eventdata, handles) % hObject handle to axes3 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) rotate3d(handles.axes3,'on'); % --- Executes on key press over figure1 with no controls selected. function figure1_KeyPressFcn(hObject, eventdata, handles) % hObject handle to figure1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % -------------------------------------------------------------------- function uniform_Callback(hObject, eventdata, handles) % hObject handle to uniform (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) set(handles.xjumps,'Value',1); set(handles.yjumps,'Value',1); set(handles.invert,'BackGroundColor','default','ForeGroundColor','default'); set(handles.xjumps,'String',['Uniform [0,1] ';'Uniform [0,5] ';'Uniform [-1/2,1/2]';'Exponential a=1 ';'Exponential a=5 ']); set(handles.yjumps,'String',['Uniform [0,1] ';'Uniform [0,5] ';'Uniform [-1/2,1/2]';'Exponential a=1 ';'Exponential a=5 ']); handles.vlowxlim=0; handles.vlowylim=0; handles.vupxlim=100; handles.vupylim=100; set(handles.lowxlim,'String','0'); set(handles.lowylim,'String','0'); set(handles.upxlim,'String','100'); set(handles.upylim,'String','100'); handles.shift=0; handles.powx=1; handles.powy=1; set(handles.powerx,'String','1'); set(handles.powery,'String','1'); handles.exp=1; handles.run=0; handles.xfun=1; handles.yfun=1; plotdensity(handles); set(handles.axes3,'ButtonDownFcn','randomwalk(''axes3_ButtonDownFcn'',gcbo,[],guidata(gcbo))'); handles.part=4000; handles.om=100; set(handles.omit,'String','100'); handles.pos=zeros(4000,2); handles.time=zeros(4000,1); handles.realtime=0; plot(handles.axes1,0,0,'.'); xlim(handles.axes1,[0,100]); ylim(handles.axes1,[0,100]); plot(handles.axes2,0,0,'.'); guidata(hObject,handles); % -------------------------------------------------------------------- function exponential_Callback(hObject, eventdata, handles) % hObject handle to exponential (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) set(handles.xjumps,'Value',1); set(handles.yjumps,'Value',5); set(handles.invert,'BackGroundColor','default','ForeGroundColor','default'); set(handles.xjumps,'String',['Uniform [0,1] ';'Uniform [0,5] ';'Uniform [-1/2,1/2]';'Exponential a=1 ';'Exponential a=5 ']); set(handles.yjumps,'String',['Uniform [0,1] ';'Uniform [0,5] ';'Uniform [-1/2,1/2]';'Exponential a=1 ';'Exponential a=5 ']); handles.vlowxlim=0; handles.vlowylim=0; handles.vupxlim=1000; handles.vupylim=1000; set(handles.lowxlim,'String','0'); set(handles.lowylim,'String','0'); set(handles.upxlim,'String','1000'); set(handles.upylim,'String','1000'); handles.shift=0; handles.powx=1; handles.powy=1; set(handles.powerx,'String','1'); set(handles.powery,'String','1'); handles.exp=1; handles.run=0; handles.xfun=1; handles.yfun=5; plotdensity(handles); set(handles.axes3,'ButtonDownFcn','randomwalk(''axes3_ButtonDownFcn'',gcbo,[],guidata(gcbo))'); handles.part=4000; handles.om=20; set(handles.omit,'String','20'); handles.pos=zeros(4000,2); handles.time=zeros(4000,1); handles.realtime=0; plot(handles.axes1,0,0,'.'); xlim(handles.axes1,[0,1000]); ylim(handles.axes1,[0,1000]); plot(handles.axes2,0,0,'.'); guidata(hObject,handles); % -------------------------------------------------------------------- function symmetric_Callback(hObject, eventdata, handles) % hObject handle to symmetric (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) set(handles.xjumps,'Value',3); set(handles.yjumps,'Value',3); set(handles.invert,'BackGroundColor','b','ForeGroundColor','r'); set(handles.xjumps,'String',['1/Uniform [0,1] ';'1/Uniform [0,5] ';'1/Uniform [-1/2,1/2]';'1/Exponential a=1 ';'1/Exponential a=5 ']); set(handles.yjumps,'String',['1/Uniform [0,1] ';'1/Uniform [0,5] ';'1/Uniform [-1/2,1/2]';'1/Exponential a=1 ';'1/Exponential a=5 ']); handles.vlowxlim=-10000; handles.vlowylim=-10000; handles.vupxlim=10000; handles.vupylim=10000; set(handles.lowxlim,'String','-10000'); set(handles.lowylim,'String','-10000'); set(handles.upxlim,'String','10000'); set(handles.upylim,'String','10000'); handles.shift=0; handles.powx=1; handles.powy=1; set(handles.powerx,'String','1'); set(handles.powery,'String','1'); handles.exp=-1; handles.run=0; handles.xfun=3; handles.yfun=3; plotdensity(handles); set(handles.axes3,'ButtonDownFcn','randomwalk(''axes3_ButtonDownFcn'',gcbo,[],guidata(gcbo))'); handles.part=4000; handles.om=100; set(handles.omit,'String','100'); handles.pos=zeros(4000,2); handles.time=zeros(4000,1); handles.realtime=0; plot(handles.axes1,0,0,'.'); xlim(handles.axes1,[0,10000]); ylim(handles.axes1,[0,10000]); plot(handles.axes2,0,0,'.'); guidata(hObject,handles); % -------------------------------------------------------------------- function plotcdf_Callback(hObject, eventdata, handles) % hObject handle to makemovie (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) figure(2) scrsize=get(0,'ScreenSize'); scrsize(2)=scrsize(4)*.1; scrsize(4)=scrsize(4).*.9; set(gcf,'Position',scrsize); xsort=sort(handles.pos(:,1)); loglog(xsort,1-[1:length(xsort)]./length(xsort),'.'); set(gca,'FontSize',18); xlabel('x','FontSize',24); ylabel('Pr\{X>x\}','FontSize',24); % -------------------------------------------------------------------- function extras_Callback(hObject, eventdata, handles) % hObject handle to extras (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % -------------------------------------------------------------------- function stable_Callback(hObject, eventdata, handles) % hObject handle to stable (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) set(handles.xjumps,'Value',1); set(handles.yjumps,'Value',1); set(handles.invert,'BackGroundColor','b','ForeGroundColor','r','String','1/jump'); set(handles.xjumps,'String',['1/Uniform [0,1] ';'1/Uniform [0,5] ';'1/Uniform [-1/2,1/2]';'1/Exponential a=1 ';'1/Exponential a=5 ']); set(handles.yjumps,'String',['1/Uniform [0,1] ';'1/Uniform [0,5] ';'1/Uniform [-1/2,1/2]';'1/Exponential a=1 ';'1/Exponential a=5 ']); handles.vlowxlim=0; handles.vlowylim=0; handles.vupxlim=10000; handles.vupylim=10000; set(handles.lowxlim,'String','0'); set(handles.lowylim,'String','0'); set(handles.upxlim,'String','10000'); set(handles.upylim,'String','10000'); handles.shift=0; handles.powx=1; handles.powy=1; set(handles.powerx,'String','1'); set(handles.powery,'String','1'); handles.exp=-1; handles.run=0; handles.xfun=1; handles.yfun=1; plotdensity(handles); set(handles.axes3,'ButtonDownFcn','randomwalk(''axes3_ButtonDownFcn'',gcbo,[],guidata(gcbo))'); handles.part=4000; handles.time=zeros(4000,1); handles.realtime=0; handles.om=100; set(handles.omit,'String','100'); handles.pos=zeros(4000,2); plot(handles.axes1,0,0,'.'); xlim(handles.axes1,[0,10000]); ylim(handles.axes1,[0,10000]); plot(handles.axes2,0,0,'.'); guidata(hObject,handles); % -------------------------------------------------------------------- function scenario_Callback(hObject, eventdata, handles) % hObject handle to scenario (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % -------------------------------------------------------------------- function finvar_Callback(hObject, eventdata, handles) % hObject handle to finvar (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) handles.shift=0.0001; handles.exp=-1; set(handles.xjumps,'String',['1/(Uniform [0,1]+0.0001) ';'1/(Uniform [0,5]+0.0001) ';'1/(Uniform [-1/2,1/2]+0.0001)';'1/(Exponential a=1+0.0001) ';'1/(Exponential a=5+0.0001) ']); set(handles.yjumps,'String',['1/(Uniform [0,1]+0.0001) ';'1/(Uniform [0,5]+0.0001) ';'1/(Uniform [-1/2,1/2]+0.0001)';'1/(Exponential a=1+0.0001) ';'1/(Exponential a=5+0.0001) ']); guidata(hObject,handles); % -------------------------------------------------------------------- function test_Callback(hObject, eventdata, handles) % hObject handle to test (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) function powerx_Callback(hObject, eventdata, handles) % hObject handle to powerx (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of powerx as text % str2double(get(hObject,'String')) returns contents of powerx as a double x=str2double(get(hObject,'String')); if isfloat(x)&isfinite(x) handles.powx=x; guidata(hObject,handles); plotdensity(handles); else set(hObject,'String',num2str(handles.powx)); end % --- Executes during object creation, after setting all properties. function powerx_CreateFcn(hObject, eventdata, handles) % hObject handle to powerx (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc set(hObject,'BackgroundColor','white'); else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end function powery_Callback(hObject, eventdata, handles) % hObject handle to powery (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of powery as text % str2double(get(hObject,'String')) returns contents of powery as a double y=str2double(get(hObject,'String')); if isfloat(y)&isfinite(y) handles.powy=y; guidata(hObject,handles); plotdensity(handles); else set(hObject,'String',num2str(handles.powy)); end % --- Executes during object creation, after setting all properties. function powery_CreateFcn(hObject, eventdata, handles) % hObject handle to powery (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc set(hObject,'BackgroundColor','white'); else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end % --- Executes on selection change in waitfcn. function waitfcn_Callback(hObject, eventdata, handles) % hObject handle to waitfcn (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: contents = get(hObject,'String') returns waitfcn contents as cell array % contents{get(hObject,'Value')} returns selected item from waitfcn handles.waitfun=get(hObject,'Value'); guidata(hObject,handles); % --- Executes during object creation, after setting all properties. function waitfcn_CreateFcn(hObject, eventdata, handles) % hObject handle to waitfcn (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: popupmenu controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc set(hObject,'BackgroundColor','white'); else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end function tvec=waitfun(v,tvec) % returns waiting time according to function selected switch v case 1 tvec=tvec+1; case 2 tvec=10*rand(length(tvec),1)+tvec; case 3 tvec=rand(length(tvec),1).^(-1./0.7)+tvec; case 4 tvec=rand(length(tvec),1).^(-1./1.7)+tvec; end % -------------------------------------------------------------------- function makemovie_Callback(hObject, eventdata, handles) % hObject handle to makemovie (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) handles.F=getframe(gcf); guidata(hObject,handles);