function varargout = diffgg01(varargin)
% DIFFGG01 M-file for diffgg01.fig
% DIFFGG01, by itself, creates a new DIFFGG01 or raises the existing
% singleton*.
%
% H = DIFFGG01 returns the handle to a new DIFFGG01 or the handle to
% the existing singleton*.
%
% DIFFGG01('Property','Value',...) creates a new DIFFGG01 using the
% given property value pairs. Unrecognized properties are passed via
% varargin to diffgg01_OpeningFcn. This calling syntax produces a
% warning when there is an existing singleton*.
%
% DIFFGG01('CALLBACK') and DIFFGG01('CALLBACK',hObject,...) call the
% local function named CALLBACK in DIFFGG01.M with the given input
% arguments.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES

% Edit the above text to modify the response to help diffgg01

% Last Modified by GUIDE v2.5 12-Aug-2004 13:31:02

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @diffgg01_OpeningFcn, ...
'gui_OutputFcn', @diffgg01_OutputFcn, ...
'gui_LayoutFcn', [], ...
'gui_Callback', []);
if nargin & isstr(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 diffgg01 is made visible.
function diffgg01_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 unrecognized PropertyName/PropertyValue pairs from the
% command line (see VARARGIN)

% Choose default command line output for diffgg01
handles.output = hObject;
load precomputed;
handles.eigen=eigenVals;
handles.labels=labels;
handles.U=eigenVecs;
handles.normalization=normalization;
handles.currind=[];
handles.eigenscale=1;
handles.index=0;
handles.time=1;set(handles.TimeValueEdit,'String',num2str(handles.time));
handles.probathreshold=5;set(handles.ProbabilityThresholdEdit,'String',num2str(handles.probathreshold));
handles.relerror=2;set(handles.RelativeErrorEdit,'String',num2str(handles.relerror));
handles.azimuth=30;handles.elevation=45;
handles.shadingFlag=0;set(handles.shadingButton,'Value',0);
handles.i=1;handles.j=2;handles.k=3;
handles.pattern=[1 0 0 0 0 0 0 0 0; 0 1 0 0 0 0 0 0 0; 0 0 1 0 0 0 0 0 0];
set(handles.StringSwitch,'String','Probability threshold (%)');
set(handles.radioRisk,'Value',1);set(handles.radioDiffusion,'Value',0);
set(handles.eigenSlider,'Value',handles.eigenscale);
% Update handles structure
guidata(hObject, handles);
UpdateRadio(hObject,eventdata,handles);
%guidata(hObject, handles);
handles=guidata(hObject);
updateEigenNumber(hObject,eventdata,handles);
handles=guidata(hObject);
%InitData(hObject,eventdata,handles);
%guidata(hObject, handles);
updateAxes2(hObject,eventdata,handles);
updateAxes3(hObject,eventdata,handles);
handles=guidata(hObject);
% UIWAIT makes diffgg01 wait for user response (see UIRESUME)
% uiwait(handles.figure1);

% --- Outputs from this function are returned to the command line.
function varargout = diffgg01_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 during object creation, after setting all properties.
function TimeValueEdit_CreateFcn(hObject, eventdata, handles)
% hObject handle to TimeValueEdit (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 TimeValueEdit_Callback(hObject, eventdata, handles)
% hObject handle to TimeValueEdit (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 TimeValueEdit as text
% str2double(get(hObject,'String')) returns contents of TimeValueEdit as a double
entry=str2double(get(hObject,'String'));
if(((~isnan(entry))&(entry>0)))
handles.time=entry;
if(handles.updateflag)
T=handles.time;
U=handles.U;
handles.Hx=handles.eigen(handles.i+1)^T*U(:,handles.i+1);
handles.Hy=handles.eigen(handles.j+1)^T*U(:,handles.j+1);
handles.Hz=handles.eigen(handles.k+1)^T*U(:,handles.k+1);
end
end
guidata(hObject, handles);
updateDistrib(hObject,eventdata,handles);
handles=guidata(hObject);
guidata(hObject,handles);
updateAxes1(hObject,eventdata,handles);
updateAxes2(hObject,eventdata,handles);
updateAxes3(hObject,eventdata,handles);
updateAxes4(hObject,eventdata,handles);

% --- Executes during object creation, after setting all properties.
function ProbabilityThresholdEdit_CreateFcn(hObject, eventdata, handles)
% hObject handle to ProbabilityThresholdEdit (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 ProbabilityThresholdEdit_Callback(hObject, eventdata, handles)
% hObject handle to ProbabilityThresholdEdit (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 ProbabilityThresholdEdit as text
% str2double(get(hObject,'String')) returns contents of ProbabilityThresholdEdit as a double
entry=str2double(get(hObject,'String'));
if(get(handles.radioRisk,'Value')==1)
if((~isnan(entry))&(entry>=0)&(entry<=100))
handles.probathreshold=entry;
end
else
if((~isnan(entry))&(entry>=0))
handles.probathreshold=entry;
end
end
set(handles.ProbabilityThresholdEdit,'String',num2str(handles.probathreshold));
guidata(hObject, handles);
if(handles.updateflag)
updateDistrib(hObject,eventdata,handles);
handles=guidata(hObject);
guidata(hObject,handles);
updateAxes1(hObject,eventdata,handles);
updateAxes2(hObject,eventdata,handles);
updateAxes4(hObject,eventdata,handles);
end

% --- Executes during object creation, after setting all properties.
function RelativeErrorEdit_CreateFcn(hObject, eventdata, handles)
% hObject handle to RelativeErrorEdit (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 RelativeErrorEdit_Callback(hObject, eventdata, handles)
% hObject handle to RelativeErrorEdit (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 RelativeErrorEdit as text
% str2double(get(hObject,'String')) returns contents of RelativeErrorEdit as a double
entry=str2double(get(hObject,'String'));
if((~isnan(entry))&(entry>=0)&(entry<=100))
handles.relerror=entry;
end
set(handles.RelativeErrorEdit,'String',num2str(handles.relerror));
guidata(hObject, handles);
if(handles.updateflag)
updateEigenNumber(hObject,eventdata,handles);
handles=guidata(hObject);
guidata(hObject,handles);
updateDistrib(hObject,eventdata,handles);
handles=guidata(hObject);
guidata(hObject,handles);
updateAxes1(hObject,eventdata,handles);
updateAxes2(hObject,eventdata,handles);
updateAxes3(hObject,eventdata,handles);
updateAxes4(hObject,eventdata,handles);
end

function updateEigenNumber(hObject,eventdata,handles)
T=handles.time;
ind=find(handles.eigen.^T>=handles.eigen(1)^T*handles.relerror/100);
handles.eigenNumber=max(ind);
guidata(hObject,handles);

% --- Executes on button press in UpdateButton.
function UpdateButton_Callback(hObject, eventdata, handles)
% hObject handle to UpdateButton (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
set(handles.UpdateButton,'String','BUSY: computing SVD');
D=squareform(pdist(handles.dataset));
a=handles.redconductivity;b=handles.blueconductivity;
D(handles.label0,handles.label0)=D(handles.label0,handles.label0)/a^2;
D(handles.label0,handles.label1)=D(handles.label0,handles.label1)/b^2;
D(handles.label1,handles.label0)=D(handles.label1,handles.label0)/b^2;
D(handles.label1,handles.label1)=D(handles.label1,handles.label1)/b^2;%b prevails over a
K1=exp(-(D/handles.sigma).^2);
v=sqrt(sum(K1));v=v(:);
K=K1./(v*v');
disp('Kernel formed, computation of SVD in progress...');
[U,S,V]=svd(K);
disp('...eigenfunctions computed');
eigen=diag(S);
i=handles.i+1;j=handles.j+1;k=handles.k+1;
handles.eigen=eigen(:);
handles.U=U;
handles.normalization=v(:);
T=handles.time;
handles.updateflag=1;
Hx=sqrt(handles.eigen(i))^T*U(:,i);
Hy=sqrt(handles.eigen(j))^T*U(:,j);
Hz=sqrt(handles.eigen(k))^T*U(:,k);
handles.com=[mean(Hx) mean(Hy) mean(Hz)];
handles.radius=sqrt(max((Hx-mean(Hx)).^2+(Hy-mean(Hy)).^2+(Hz-mean(Hz)).^2));
handles.Hx=Hx;handles.Hy=Hy;handles.Hz=Hz;
set(gca,'XTickLabel',{});set(gca,'YTickLabel',{});
set(gca,'ButtonDownFcn',@gotyou2);
set(handles.UpdateButton,'String','Update diffusion');
guidata(hObject, handles);
updateAxes2(hObject,eventdata,handles);
updateAxes3(hObject,eventdata,handles);
guidata(hObject, handles);
updateEigenNumber(hObject,eventdata,handles);
handles=guidata(hObject);

function UpdateRadio(hObject,eventdata,handles)
pattern=handles.pattern;
set(handles.radiobutton1,'Value',pattern(1,1));
set(handles.radiobutton2,'Value',pattern(1,2));
set(handles.radiobutton3,'Value',pattern(1,3));
set(handles.radiobutton4,'Value',pattern(1,4));
set(handles.radiobutton5,'Value',pattern(1,5));
set(handles.radiobutton6,'Value',pattern(1,6));
set(handles.radiobutton7,'Value',pattern(1,7));
set(handles.radiobutton8,'Value',pattern(1,8));
set(handles.radiobutton9,'Value',pattern(1,9));
set(handles.radiobutton10,'Value',pattern(2,1));
set(handles.radiobutton11,'Value',pattern(2,2));
set(handles.radiobutton12,'Value',pattern(2,3));
set(handles.radiobutton13,'Value',pattern(2,4));
set(handles.radiobutton14,'Value',pattern(2,5));
set(handles.radiobutton15,'Value',pattern(2,6));
set(handles.radiobutton16,'Value',pattern(2,7));
set(handles.radiobutton17,'Value',pattern(2,8));
set(handles.radiobutton18,'Value',pattern(2,9));
set(handles.radiobutton19,'Value',pattern(3,1));
set(handles.radiobutton20,'Value',pattern(3,2));
set(handles.radiobutton21,'Value',pattern(3,3));
set(handles.radiobutton22,'Value',pattern(3,4));
set(handles.radiobutton23,'Value',pattern(3,5));
set(handles.radiobutton24,'Value',pattern(3,6));
set(handles.radiobutton25,'Value',pattern(3,7));
set(handles.radiobutton26,'Value',pattern(3,8));
set(handles.radiobutton27,'Value',pattern(3,9));
i=handles.i+1;j=handles.j+1;k=handles.k+1;
T=handles.time;U=handles.U;
Hx=sqrt(handles.eigen(i))^T*U(:,i);
Hy=sqrt(handles.eigen(j))^T*U(:,j);
Hz=sqrt(handles.eigen(k))^T*U(:,k);
handles.com=[mean(Hx) mean(Hy) mean(Hz)];
handles.radius=sqrt(max((Hx-mean(Hx)).^2+(Hy-mean(Hy)).^2+(Hz-mean(Hz)).^2));
handles.Hx=Hx;handles.Hy=Hy;handles.Hz=Hz;
guidata(hObject, handles);
updateAxes2(hObject,eventdata,handles);

function InitData(hObject,eventdata,handles)
updateEigenNumber(hObject,eventdata,handles);
axes(handles.axes2);cla;
set(gca,'ButtonDownFcn',@gotyou2);
axes(handles.axes3);cla;
set(gca,'ButtonDownFcn',@gotyou3);
set(gca,'YTickLabel',{});
set(handles.eigenSlider,'Value',handles.eigenscale);
axes(handles.axes4);cla;
set(gca,'ButtonDownFcn',@gotyou4);
set(gca,'XTickLabel',{});set(gca,'YTickLabel',{});
guidata(hObject,handles);

% --- Executes on button press in RotXR.
function RotXR_Callback(hObject, eventdata, handles)
% hObject handle to RotXR (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
handles.azimuth=handles.azimuth+10;
guidata(hObject,handles);
updateAxes2(hObject,eventdata,handles);
guidata(hObject,handles);

% --- Executes on button press in RotXL.
function RotXL_Callback(hObject, eventdata, handles)
% hObject handle to RotXL (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
handles.azimuth=handles.azimuth-10;
guidata(hObject,handles);
updateAxes2(hObject,eventdata,handles);
guidata(hObject,handles);

% --- Executes on button press in RotYL.
function RotYL_Callback(hObject, eventdata, handles)
% hObject handle to RotYL (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
handles.elevation=handles.elevation-5;
if (handles.elevation<=-90)
handles.elevation=-89;
end
guidata(hObject,handles);
updateAxes2(hObject,eventdata,handles);
guidata(hObject,handles);

% --- Executes on button press in RotYR.
function RotYR_Callback(hObject, eventdata, handles)
% hObject handle to RotYR (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
handles.elevation=handles.elevation+5;
if (handles.elevation>=90)
handles.elevation=89;
end
guidata(hObject,handles);
updateAxes2(hObject,eventdata,handles);
guidata(hObject,handles);

function updateDistrib(hObject,eventdata,handles)
if (handles.index==0)
return;
end
T=handles.time;
index=handles.index;
ind=1:handles.eigenNumber;
if(get(handles.radioRisk,'Value')==1)
a=((handles.eigen(ind).^T)'.*(handles.U(index,ind)))*handles.U(:,ind)';
transition=a.*handles.normalization'/handles.normalization(index);
newind=find(transition>handles.probathreshold/100*max(transition));
handles.distrib=transition;
handles.arow=a;
[tmp,ind]=sort(transition(newind));
newind=fliplr(newind(ind));
else
[N,tmp]=size(handles.dataset);
tmp1=ones(N,1)*handles.U(index,ind)-handles.U(:,ind);
tmp2=tmp1.^2;
tmp3=sqrt(tmp2*((handles.eigen(ind)).^T));
newind=find(tmp3<handles.probathreshold);
handles.distrib=(tmp3);
a=(handles.U(:,ind))*diag(handles.eigen(ind).^T)*(handles.U(:,ind)');
handles.arow=a(index,:);
[tmp,ind]=sort(tmp3(newind));
newind=newind(ind);
end
handles.currind=newind;
guidata(hObject,handles);

function gotyou1(hObject,eventdata)
handles=guidata(hObject);%guidata(gcbo);
if (~handles.updateflag)
UpdateButton_Callback(hObject, [], handles);
end
handles=guidata(hObject);
Gx=handles.Gx;
Gy=handles.Gy;
pos=get(handles.axes1,'CurrentPoint');
xm=pos(1,1);ym=pos(1,2);
D2=(Gx-xm).^2+(Gy-ym).^2;
[tmp,index]=min(D2);
handles.index=index;
guidata(hObject,handles);
updateDistrib(hObject,eventdata,handles);
handles=guidata(hObject);
guidata(hObject,handles);
updateAxes1(hObject,eventdata,handles);
updateAxes2(hObject,eventdata,handles);
updateAxes4(hObject,eventdata,handles);

function gotyou2(hObject,eventdata)
handles=guidata(hObject);
pos=get(handles.axes2,'CurrentPoint');
xm=pos(1,1);ym=pos(1,2);
Hx=handles.Hx;Hy=handles.Hy;Hz=handles.Hz;
projo=viewmtx(handles.azimuth,handles.elevation);
points=[Hx';Hy';Hz';ones(1,length(Hx))];
projoPoints=projo*points;
xp=projoPoints(1,:);yp=projoPoints(2,:);
D2=(xp-xm).^2+(yp-ym).^2;
[tmp,index]=min(D2);
handles.index=index;
guidata(hObject,handles);
updateDistrib(hObject,eventdata,handles);
handles=guidata(hObject);
guidata(hObject,handles);
%updateAxes1(hObject,eventdata,handles);
updateAxes2(hObject,eventdata,handles);
updateAxes4(hObject,eventdata,handles);

function gotyou3(hObject,eventdata);
handles=guidata(hObject);
pos=get(handles.axes3,'CurrentPoint');
N=length(handles.eigen);
xm=pos(1,1);
xm=round(xm);
if((xm>=1)&(xm<=N))
T=handles.time;
handles.relerror=100*(handles.eigen(xm)/handles.eigen(1))^T;
handles.eigenNumber=xm;
set(handles.RelativeErrorEdit,'String',num2str(handles.relerror));
guidata(hObject,handles);
updateDistrib(hObject,eventdata,handles);
handles=guidata(hObject);
guidata(hObject,handles);
% updateAxes1(hObject,eventdata,handles);
updateAxes2(hObject,eventdata,handles);
updateAxes3(hObject,eventdata,handles);
updateAxes4(hObject,eventdata,handles);
end

function gotyou4(hObject,eventdata);
handles=guidata(hObject);
pos=get(handles.axes4,'CurrentPoint');
ym=pos(1,2);
if((ym>=0)&(ym<=max(handles.distrib)))
if(get(handles.radioRisk,'Value')==1)
handles.probathreshold=ceil(ym/max(handles.distrib)*100);
set(handles.ProbabilityThresholdEdit,'String',num2str(handles.probathreshold));
guidata(hObject,handles);
updateDistrib(hObject,eventdata,handles);
handles=guidata(hObject);
guidata(hObject,handles);
%updateAxes1(hObject,eventdata,handles);
updateAxes2(hObject,eventdata,handles);
updateAxes4(hObject,eventdata,handles);
else
handles.probathreshold=ym;
set(handles.ProbabilityThresholdEdit,'String',num2str(handles.probathreshold));
guidata(hObject,handles);
updateDistrib(hObject,eventdata,handles);
handles=guidata(hObject);
guidata(hObject,handles);
%updateAxes1(hObject,eventdata,handles);
updateAxes2(hObject,eventdata,handles);
updateAxes4(hObject,eventdata,handles);
end
end

function updateAxes1(hObject, eventdata, handles)
axes(handles.axes1);cla;hold off;
Gx=handles.Gx;Gy=handles.Gy;
h=plot(Gx(handles.label0),Gy(handles.label0),'r.');
set(h,'HitTest','Off');
hold on;h=plot(Gx(handles.label1),Gy(handles.label1),'b.');
set(h,'HitTest','Off');
h=plot(Gx(handles.currind),Gy(handles.currind),'g*');hold off;
set(h,'HitTest','Off');
set(gca,'XTickLabel',{});set(gca,'YTickLabel',{});
Lx=max(Gx)-min(Gx);Ly=max(Gy)-min(Gy);
axis([max(Gx)-1.1*Lx,min(Gx)+1.1*Lx,max(Gy)-1.1*Ly,min(Gy)+1.1*Ly]);
daspect([1 1 1]);
set(gca,'ButtonDownFcn',@gotyou1);

function updateAxes2(hObject,eventdata, handles)
axes(handles.axes2);cla;
Hx=handles.Hx;
Hy=handles.Hy;
Hz=handles.Hz;
projo=viewmtx(handles.azimuth,handles.elevation);
points=[Hx';Hy';Hz';ones(1,length(Hx))];
projoPoints=projo*points;
xp=projoPoints(1,:);yp=projoPoints(2,:);zp=projoPoints(3,:);zp=zp(:);
hold off;
if (handles.shadingFlag==0)
ind=find(handles.labels(:,2)==1);
h=plot(xp(ind),yp(ind),'r.');
set(h,'HitTest','Off');
hold on;
ind=find(handles.labels(:,2)==2);
h=plot(xp(ind),yp(ind),'b.');
set(h,'HitTest','Off');
hold on;
ind=find(handles.labels(:,2)==3);
h=plot(xp(ind),yp(ind),'.','Color',[.1 .5 0]);
set(h,'HitTest','Off');
hold on;
ind=find(handles.labels(:,2)==4);
h=plot(xp(ind),yp(ind),'c.');
set(h,'HitTest','Off');
hold on;
ind=find(handles.labels(:,2)==5);
h=plot(xp(ind),yp(ind),'m.');
set(h,'HitTest','Off');
hold on;
ind=find(handles.labels(:,2)==6);
h=plot(xp(ind),yp(ind),'y.');
set(h,'HitTest','Off');
hold on;
ind=find(handles.labels(:,2)==7);
h=plot(xp(ind),yp(ind),'k.');
set(h,'HitTest','Off');
hold on;
ind=find(handles.labels(:,2)==8);
h=plot(xp(ind),yp(ind),'.','Color',[.5 .5 .5]);
set(h,'HitTest','Off');
hold on;
h=plot(xp(handles.currind),yp(handles.currind),'g*');
set(h,'HitTest','Off');
else
minzp=min(zp);maxzp=max(zp);
ind=find((zp<=minzp+(maxzp-minzp)/3)&(handles.label==0));
h=plot(xp(ind),yp(ind),'.','Color',[.4 0 0]);
set(h,'HitTest','Off');
hold on;
ind=find((zp>minzp+(maxzp-minzp)/3)&(zp<=minzp+(maxzp-minzp)*2/3)&(handles.label==0));
h=plot(xp(ind),yp(ind),'.','Color',[.7 0 0]);
set(h,'HitTest','Off');
ind=find((zp>minzp+(maxzp-minzp)*2/3)&(handles.label==0));
h=plot(xp(ind),yp(ind),'.','Color',[1 .1 .1]);
set(h,'HitTest','Off');
ind=find((zp<=minzp+(maxzp-minzp)/3)&(handles.label==1));
h=plot(xp(ind),yp(ind),'.','Color',[0 0 .4]);
set(h,'HitTest','Off');
ind=find((zp>minzp+(maxzp-minzp)/3)&(zp<=minzp+(maxzp-minzp)*2/3)&(handles.label==1));
h=plot(xp(ind),yp(ind),'.','Color',[0 0 .7]);
set(h,'HitTest','Off');
ind=find((zp>minzp+(maxzp-minzp)*2/3)&(handles.label==1));
h=plot(xp(ind),yp(ind),'.','Color',[.1 .1 1]);
set(h,'HitTest','Off');
tmp=zeros(size(zp));tmp(handles.currind)=1;
ind=find((zp<=minzp+(maxzp-minzp)/3)&(tmp==1));
h=plot(xp(ind),yp(ind),'.','Color',[0 .4 0]);
set(h,'HitTest','Off');
ind=find((zp>minzp+(maxzp-minzp)/3)&(zp<=minzp+(maxzp-minzp)*2/3)&(tmp==1));
h=plot(xp(ind),yp(ind),'.','Color',[0 .7 0]);
set(h,'HitTest','Off');
ind=find((zp>minzp+(maxzp-minzp)*2/3)&(tmp==1));
h=plot(xp(ind),yp(ind),'.','Color',[.1 1 .1]);
set(h,'HitTest','Off');
end
comProjo=projo*[handles.com';1];
axis([comProjo(1)-1.1*handles.radius,comProjo(1)+1.1*handles.radius,comProjo(2)-1.1*handles.radius,comProjo(2)+1.1*handles.radius]);
hold off;
set(gca,'XTickLabel',{});set(gca,'YTickLabel',{});
set(gca,'ButtonDownFcn',{@gotyou2});

function updateAxes3(hObject,eventdata,handles)
axes(handles.axes3);cla;hold off;
N=length(handles.eigen);
p=ceil(N*handles.eigenscale);
if(p<=1)
p=2;
end
T=handles.time;
ind=find((handles.eigen/handles.eigen(1)).^T>=handles.relerror/100);
h=plot(handles.eigen(1:p).^T,'k');
set(h,'HitTest','Off');
hold on;
h=line([1,p],[handles.relerror/100,handles.relerror/100]);
set(h,'HitTest','Off');set(h,'Color','g');
h=line([max(ind),max(ind)],[0,handles.relerror/100]);
set(h,'HitTest','Off');set(h,'Color','g');
axis([1,p,0,1]);
hold off;
set(gca,'ButtonDownFcn',{@gotyou3});

function updateAxes4(hObject,eventdata,handles)
if(handles.index==0)
return;
end
axes(handles.axes4);cla;hold off;
N=length(handles.distrib);
h=plot(handles.distrib,'k');
set(h,'HitTest','Off');
hold on;
if(get(handles.radioRisk,'Value')==1)
h=line([1,N],[handles.probathreshold/100,handles.probathreshold/100]*max(handles.distrib));
set(h,'HitTest','Off');set(h,'Color','g');
% set(handles.legendText,'String','Legend: black=distribution, green=threshold.');
else
if(handles.probathreshold<=max(handles.distrib))
h=line([1,N],[handles.probathreshold,handles.probathreshold]);
set(h,'HitTest','Off');set(h,'Color','g');
end
ind=find(handles.arow<max(handles.arow)*1e-2);
h=plot(ind,handles.distrib(ind),'.','Color',[.5 .5 .5]);
set(h,'HitTest','Off');
% set(handles.legendText,'String','Legend: black=distribution, green=threshold, grey=irrelevant points.');
end
axis([1,N,-.05*max(handles.distrib),1.1*max(handles.distrib)]);
hold off;
set(gca,'YTickLabel',{});
set(gca,'ButtonDownFcn',{@gotyou4});

% --- Executes on button press in shadingButton.
function shadingButton_Callback(hObject, eventdata, handles)
% hObject handle to shadingButton (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of shadingButton
handles.shadingFlag=1-handles.shadingFlag;
guidata(hObject,handles);
if(handles.updateflag)
updateAxes2(hObject,eventdata,handles);
end;

% --- Executes on button press in radiobutton1.
function radiobutton1_Callback(hObject, eventdata, handles)
% hObject handle to radiobutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of radiobutton1
val=1;
handles.pattern(1,handles.i)=0;
if(handles.j==val)
handles.pattern(2,handles.j)=0;
handles.j=handles.i;handles.pattern(2,handles.j)=1;
elseif (handles.k==val)
handles.pattern(3,handles.k)=0;
handles.k=handles.i;handles.pattern(3,handles.k)=1;
end
handles.i=val;
handles.pattern(1,handles.i)=1;
guidata(hObject,handles);
UpdateRadio(hObject,eventdata,handles);
handles=guidata(hObject);
updateAxes2(hObject,eventdata,handles);
guidata(hObject,handles);

% --- Executes on button press in radiobutton2.
function radiobutton2_Callback(hObject, eventdata, handles)
% hObject handle to radiobutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of radiobutton2
val=2;
handles.pattern(1,handles.i)=0;
if(handles.j==val)
handles.pattern(2,handles.j)=0;
handles.j=handles.i;handles.pattern(2,handles.j)=1;
elseif (handles.k==val)
handles.pattern(3,handles.k)=0;
handles.k=handles.i;handles.pattern(3,handles.k)=1;
end
handles.i=val;
handles.pattern(1,handles.i)=1;
guidata(hObject,handles);
UpdateRadio(hObject,eventdata,handles);
handles=guidata(hObject);
updateAxes2(hObject,eventdata,handles);
guidata(hObject,handles);

% --- Executes on button press in radiobutton3.
function radiobutton3_Callback(hObject, eventdata, handles)
% hObject handle to radiobutton3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of radiobutton3
val=3;
handles.pattern(1,handles.i)=0;
if(handles.j==val)
handles.pattern(2,handles.j)=0;
handles.j=handles.i;handles.pattern(2,handles.j)=1;
elseif (handles.k==val)
handles.pattern(3,handles.k)=0;
handles.k=handles.i;handles.pattern(3,handles.k)=1;
end
handles.i=val;
handles.pattern(1,handles.i)=1;
guidata(hObject,handles);
UpdateRadio(hObject,eventdata,handles);
handles=guidata(hObject);
updateAxes2(hObject,eventdata,handles);

% --- Executes on button press in radiobutton4.
function radiobutton4_Callback(hObject, eventdata, handles)
% hObject handle to radiobutton4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of radiobutton4
val=4;
handles.pattern(1,handles.i)=0;
if(handles.j==val)
handles.pattern(2,handles.j)=0;
handles.j=handles.i;handles.pattern(2,handles.j)=1;
elseif (handles.k==val)
handles.pattern(3,handles.k)=0;
handles.k=handles.i;handles.pattern(3,handles.k)=1;
end
handles.i=val;
handles.pattern(1,handles.i)=1;
guidata(hObject,handles);
UpdateRadio(hObject,eventdata,handles);
handles=guidata(hObject);
updateAxes2(hObject,eventdata,handles);

% --- Executes on button press in radiobutton5.
function radiobutton5_Callback(hObject, eventdata, handles)
% hObject handle to radiobutton5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of radiobutton5
val=5;
handles.pattern(1,handles.i)=0;
if(handles.j==val)
handles.pattern(2,handles.j)=0;
handles.j=handles.i;handles.pattern(2,handles.j)=1;
elseif (handles.k==val)
handles.pattern(3,handles.k)=0;
handles.k=handles.i;handles.pattern(3,handles.k)=1;
end
handles.i=val;
handles.pattern(1,handles.i)=1;
guidata(hObject,handles);
UpdateRadio(hObject,eventdata,handles);
handles=guidata(hObject);
updateAxes2(hObject,eventdata,handles);

% --- Executes on button press in radiobutton6.
function radiobutton6_Callback(hObject, eventdata, handles)
% hObject handle to radiobutton6 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of radiobutton6
val=6;
handles.pattern(1,handles.i)=0;
if(handles.j==val)
handles.pattern(2,handles.j)=0;
handles.j=handles.i;handles.pattern(2,handles.j)=1;
elseif (handles.k==val)
handles.pattern(3,handles.k)=0;
handles.k=handles.i;handles.pattern(3,handles.k)=1;
end
handles.i=val;
handles.pattern(1,handles.i)=1;
guidata(hObject,handles);
UpdateRadio(hObject,eventdata,handles);
handles=guidata(hObject);
updateAxes2(hObject,eventdata,handles);

% --- Executes on button press in radiobutton7.
function radiobutton7_Callback(hObject, eventdata, handles)
% hObject handle to radiobutton7 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of radiobutton7
val=7;
handles.pattern(1,handles.i)=0;
if(handles.j==val)
handles.pattern(2,handles.j)=0;
handles.j=handles.i;handles.pattern(2,handles.j)=1;
elseif (handles.k==val)
handles.pattern(3,handles.k)=0;
handles.k=handles.i;handles.pattern(3,handles.k)=1;
end
handles.i=val;
handles.pattern(1,handles.i)=1;
guidata(hObject,handles);
UpdateRadio(hObject,eventdata,handles);
handles=guidata(hObject);
updateAxes2(hObject,eventdata,handles);

% --- Executes on button press in radiobutton8.
function radiobutton8_Callback(hObject, eventdata, handles)
% hObject handle to radiobutton8 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of radiobutton8
val=8;
handles.pattern(1,handles.i)=0;
if(handles.j==val)
handles.pattern(2,handles.j)=0;
handles.j=handles.i;handles.pattern(2,handles.j)=1;
elseif (handles.k==val)
handles.pattern(3,handles.k)=0;
handles.k=handles.i;handles.pattern(3,handles.k)=1;
end
handles.i=val;
handles.pattern(1,handles.i)=1;
guidata(hObject,handles);
UpdateRadio(hObject,eventdata,handles);
handles=guidata(hObject);
updateAxes2(hObject,eventdata,handles);

% --- Executes on button press in radiobutton9.
function radiobutton9_Callback(hObject, eventdata, handles)
% hObject handle to radiobutton9 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of radiobutton9
val=9;
handles.pattern(1,handles.i)=0;
if(handles.j==val)
handles.pattern(2,handles.j)=0;
handles.j=handles.i;handles.pattern(2,handles.j)=1;
elseif (handles.k==val)
handles.pattern(3,handles.k)=0;
handles.k=handles.i;handles.pattern(3,handles.k)=1;
end
handles.i=val;
handles.pattern(1,handles.i)=1;
guidata(hObject,handles);
UpdateRadio(hObject,eventdata,handles);
handles=guidata(hObject);
updateAxes2(hObject,eventdata,handles);

% --- Executes on button press in radiobutton10.
function radiobutton10_Callback(hObject, eventdata, handles)
% hObject handle to radiobutton10 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of radiobutton10
val=1;
handles.pattern(2,handles.j)=0;
if(handles.i==val)
handles.pattern(1,handles.i)=0;
handles.i=handles.j;handles.pattern(1,handles.i)=1;
elseif (handles.k==val)
handles.pattern(3,handles.k)=0;
handles.k=handles.j;handles.pattern(3,handles.j)=1;
end
handles.j=val;
handles.pattern(2,handles.j)=1;
guidata(hObject,handles);
UpdateRadio(hObject,eventdata,handles);
handles=guidata(hObject);
updateAxes2(hObject,eventdata,handles);

% --- Executes on button press in radiobutton11.
function radiobutton11_Callback(hObject, eventdata, handles)
% hObject handle to radiobutton11 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of radiobutton11
val=2;
handles.pattern(2,handles.j)=0;
if(handles.i==val)
handles.pattern(1,handles.i)=0;
handles.i=handles.j;handles.pattern(1,handles.i)=1;
elseif (handles.k==val)
handles.pattern(3,handles.k)=0;
handles.k=handles.j;handles.pattern(3,handles.j)=1;
end
handles.j=val;
handles.pattern(2,handles.j)=1;
guidata(hObject,handles);
UpdateRadio(hObject,eventdata,handles);
handles=guidata(hObject);
updateAxes2(hObject,eventdata,handles);

% --- Executes on button press in radiobutton12.
function radiobutton12_Callback(hObject, eventdata, handles)
% hObject handle to radiobutton12 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of radiobutton12
val=3;
handles.pattern(2,handles.j)=0;
if(handles.i==val)
handles.pattern(1,handles.i)=0;
handles.i=handles.j;handles.pattern(1,handles.i)=1;
elseif (handles.k==val)
handles.pattern(3,handles.k)=0;
handles.k=handles.j;handles.pattern(3,handles.j)=1;
end
handles.j=val;
handles.pattern(2,handles.j)=1;
guidata(hObject,handles);
UpdateRadio(hObject,eventdata,handles);
handles=guidata(hObject);
updateAxes2(hObject,eventdata,handles);

% --- Executes on button press in radiobutton13.
function radiobutton13_Callback(hObject, eventdata, handles)
% hObject handle to radiobutton13 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of radiobutton13
val=4;
handles.pattern(2,handles.j)=0;
if(handles.i==val)
handles.pattern(1,handles.i)=0;
handles.i=handles.j;handles.pattern(1,handles.i)=1;
elseif (handles.k==val)
handles.pattern(3,handles.k)=0;
handles.k=handles.j;handles.pattern(3,handles.j)=1;
end
handles.j=val;
handles.pattern(2,handles.j)=1;
guidata(hObject,handles);
UpdateRadio(hObject,eventdata,handles);
handles=guidata(hObject);
updateAxes2(hObject,eventdata,handles);

% --- Executes on button press in radiobutton14.
function radiobutton14_Callback(hObject, eventdata, handles)
% hObject handle to radiobutton14 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of radiobutton14
val=5;
handles.pattern(2,handles.j)=0;
if(handles.i==val)
handles.pattern(1,handles.i)=0;
handles.i=handles.j;handles.pattern(1,handles.i)=1;
elseif (handles.k==val)
handles.pattern(3,handles.k)=0;
handles.k=handles.j;handles.pattern(3,handles.j)=1;
end
handles.j=val;
handles.pattern(2,handles.j)=1;
guidata(hObject,handles);
UpdateRadio(hObject,eventdata,handles);
handles=guidata(hObject);
updateAxes2(hObject,eventdata,handles);

% --- Executes on button press in radiobutton15.
function radiobutton15_Callback(hObject, eventdata, handles)
% hObject handle to radiobutton15 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of radiobutton15
val=6;
handles.pattern(2,handles.j)=0;
if(handles.i==val)
handles.pattern(1,handles.i)=0;
handles.i=handles.j;handles.pattern(1,handles.i)=1;
elseif (handles.k==val)
handles.pattern(3,handles.k)=0;
handles.k=handles.j;handles.pattern(3,handles.j)=1;
end
handles.j=val;
handles.pattern(2,handles.j)=1;
guidata(hObject,handles);
UpdateRadio(hObject,eventdata,handles);
handles=guidata(hObject);
updateAxes2(hObject,eventdata,handles);

% --- Executes on button press in radiobutton16.
function radiobutton16_Callback(hObject, eventdata, handles)
% hObject handle to radiobutton16 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of radiobutton16
val=7;
handles.pattern(2,handles.j)=0;
if(handles.i==val)
handles.pattern(1,handles.i)=0;
handles.i=handles.j;handles.pattern(1,handles.i)=1;
elseif (handles.k==val)
handles.pattern(3,handles.k)=0;
handles.k=handles.j;handles.pattern(3,handles.j)=1;
end
handles.j=val;
handles.pattern(2,handles.j)=1;
guidata(hObject,handles);
UpdateRadio(hObject,eventdata,handles);
handles=guidata(hObject);
updateAxes2(hObject,eventdata,handles);

% --- Executes on button press in radiobutton17.
function radiobutton17_Callback(hObject, eventdata, handles)
% hObject handle to radiobutton17 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of radiobutton17
val=8;
handles.pattern(2,handles.j)=0;
if(handles.i==val)
handles.pattern(1,handles.i)=0;
handles.i=handles.j;handles.pattern(1,handles.i)=1;
elseif (handles.k==val)
handles.pattern(3,handles.k)=0;
handles.k=handles.j;handles.pattern(3,handles.j)=1;
end
handles.j=val;
handles.pattern(2,handles.j)=1;
guidata(hObject,handles);
UpdateRadio(hObject,eventdata,handles);
handles=guidata(hObject);
updateAxes2(hObject,eventdata,handles);

% --- Executes on button press in radiobutton18.
function radiobutton18_Callback(hObject, eventdata, handles)
% hObject handle to radiobutton18 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of radiobutton18
val=9;
handles.pattern(2,handles.j)=0;
if(handles.i==val)
handles.pattern(1,handles.i)=0;
handles.i=handles.j;handles.pattern(1,handles.i)=1;
elseif (handles.k==val)
handles.pattern(3,handles.k)=0;
handles.k=handles.j;handles.pattern(3,handles.j)=1;
end
handles.j=val;
handles.pattern(2,handles.j)=1;
guidata(hObject,handles);
UpdateRadio(hObject,eventdata,handles);
handles=guidata(hObject);
updateAxes2(hObject,eventdata,handles);

% --- Executes on button press in radiobutton19.
function radiobutton19_Callback(hObject, eventdata, handles)
% hObject handle to radiobutton19 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of radiobutton19
val=1;
handles.pattern(3,handles.k)=0;
if(handles.i==val)
handles.pattern(1,handles.i)=0;
handles.i=handles.k;handles.pattern(1,handles.i)=1;
elseif (handles.j==val)
handles.pattern(2,handles.j)=0;
handles.j=handles.k;handles.pattern(2,handles.j)=1;
end
handles.k=val;
handles.pattern(3,handles.k)=1;
guidata(hObject,handles);
UpdateRadio(hObject,eventdata,handles);
handles=guidata(hObject);
updateAxes2(hObject,eventdata,handles);

% --- Executes on button press in radiobutton20.
function radiobutton20_Callback(hObject, eventdata, handles)
% hObject handle to radiobutton20 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of radiobutton20
val=2;
handles.pattern(3,handles.k)=0;
if(handles.i==val)
handles.pattern(1,handles.i)=0;
handles.i=handles.k;handles.pattern(1,handles.i)=1;
elseif (handles.j==val)
handles.pattern(2,handles.j)=0;
handles.j=handles.k;handles.pattern(2,handles.j)=1;
end
handles.k=val;
handles.pattern(3,handles.k)=1;
guidata(hObject,handles);
UpdateRadio(hObject,eventdata,handles);
handles=guidata(hObject);
updateAxes2(hObject,eventdata,handles);

% --- Executes on button press in radiobutton21.
function radiobutton21_Callback(hObject, eventdata, handles)
% hObject handle to radiobutton21 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of radiobutton21
val=3;
handles.pattern(3,handles.k)=0;
if(handles.i==val)
handles.pattern(1,handles.i)=0;
handles.i=handles.k;handles.pattern(1,handles.i)=1;
elseif (handles.j==val)
handles.pattern(2,handles.j)=0;
handles.j=handles.k;handles.pattern(2,handles.j)=1;
end
handles.k=val;
handles.pattern(3,handles.k)=1;
guidata(hObject,handles);
UpdateRadio(hObject,eventdata,handles);
handles=guidata(hObject);
updateAxes2(hObject,eventdata,handles);

% --- Executes on button press in radiobutton22.
function radiobutton22_Callback(hObject, eventdata, handles)
% hObject handle to radiobutton22 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of radiobutton22
val=4;
handles.pattern(3,handles.k)=0;
if(handles.i==val)
handles.pattern(1,handles.i)=0;
handles.i=handles.k;handles.pattern(1,handles.i)=1;
elseif (handles.j==val)
handles.pattern(2,handles.j)=0;
handles.j=handles.k;handles.pattern(2,handles.j)=1;
end
handles.k=val;
handles.pattern(3,handles.k)=1;
guidata(hObject,handles);
UpdateRadio(hObject,eventdata,handles);
handles=guidata(hObject);
updateAxes2(hObject,eventdata,handles);

% --- Executes on button press in radiobutton23.
function radiobutton23_Callback(hObject, eventdata, handles)
% hObject handle to radiobutton23 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of radiobutton23
val=5;
handles.pattern(3,handles.k)=0;
if(handles.i==val)
handles.pattern(1,handles.i)=0;
handles.i=handles.k;handles.pattern(1,handles.i)=1;
elseif (handles.j==val)
handles.pattern(2,handles.j)=0;
handles.j=handles.k;handles.pattern(2,handles.j)=1;
end
handles.k=val;
handles.pattern(3,handles.k)=1;
guidata(hObject,handles);
UpdateRadio(hObject,eventdata,handles);
handles=guidata(hObject);
updateAxes2(hObject,eventdata,handles);

% --- Executes on button press in radiobutton24.
function radiobutton24_Callback(hObject, eventdata, handles)
% hObject handle to radiobutton24 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of radiobutton24
val=6;
handles.pattern(3,handles.k)=0;
if(handles.i==val)
handles.pattern(1,handles.i)=0;
handles.i=handles.k;handles.pattern(1,handles.i)=1;
elseif (handles.j==val)
handles.pattern(2,handles.j)=0;
handles.j=handles.k;handles.pattern(2,handles.j)=1;
end
handles.k=val;
handles.pattern(3,handles.k)=1;
guidata(hObject,handles);
UpdateRadio(hObject,eventdata,handles);
handles=guidata(hObject);
updateAxes2(hObject,eventdata,handles);

% --- Executes on button press in radiobutton25.
function radiobutton25_Callback(hObject, eventdata, handles)
% hObject handle to radiobutton25 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of radiobutton25
val=7;
handles.pattern(3,handles.k)=0;
if(handles.i==val)
handles.pattern(1,handles.i)=0;
handles.i=handles.k;handles.pattern(1,handles.i)=1;
elseif (handles.j==val)
handles.pattern(2,handles.j)=0;
handles.j=handles.k;handles.pattern(2,handles.j)=1;
end
handles.k=val;
handles.pattern(3,handles.k)=1;
guidata(hObject,handles);
UpdateRadio(hObject,eventdata,handles);
handles=guidata(hObject);
updateAxes2(hObject,eventdata,handles);

% --- Executes on button press in radiobutton26.
function radiobutton26_Callback(hObject, eventdata, handles)
% hObject handle to radiobutton26 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of radiobutton26
val=8;
handles.pattern(3,handles.k)=0;
if(handles.i==val)
handles.pattern(1,handles.i)=0;
handles.i=handles.k;handles.pattern(1,handles.i)=1;
elseif (handles.j==val)
handles.pattern(2,handles.j)=0;
handles.j=handles.k;handles.pattern(2,handles.j)=1;
end
handles.k=val;
handles.pattern(3,handles.k)=1;
guidata(hObject,handles);
UpdateRadio(hObject,eventdata,handles);
handles=guidata(hObject);
updateAxes2(hObject,eventdata,handles);

% --- Executes on button press in radiobutton27.
function radiobutton27_Callback(hObject, eventdata, handles)
% hObject handle to radiobutton27 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of radiobutton27
val=9;
handles.pattern(3,handles.k)=0;
if(handles.i==val)
handles.pattern(1,handles.i)=0;
handles.i=handles.k;handles.pattern(1,handles.i)=1;
elseif (handles.j==val)
handles.pattern(2,handles.j)=0;
handles.j=handles.k;handles.pattern(2,handles.j)=1;
end
handles.k=val;
handles.pattern(3,handles.k)=1;
guidata(hObject,handles);
UpdateRadio(hObject,eventdata,handles);
handles=guidata(hObject);
updateAxes2(hObject,eventdata,handles);

% --- Executes during object creation, after setting all properties.
function eigenSlider_CreateFcn(hObject, eventdata, handles)
% hObject handle to eigenSlider (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called

% Hint: slider controls usually have a light gray background, change
% 'usewhitebg' to 0 to use default. See ISPC and COMPUTER.
usewhitebg = 1;
if usewhitebg
set(hObject,'BackgroundColor',[.9 .9 .9]);
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end

% --- Executes on slider movement.
function eigenSlider_Callback(hObject, eventdata, handles)
% hObject handle to eigenSlider (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,'Value') returns position of slider
% get(hObject,'Min') and get(hObject,'Max') to determine range of slider
handles.eigenscale=get(hObject,'Value');
guidata(hObject,handles);
handles=guidata(hObject);
updateAxes3(hObject,eventdata,handles);

% --- Executes on button press in radioRisk.
function radioRisk_Callback(hObject, eventdata, handles)
% hObject handle to radioRisk (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of radioRisk
set(handles.StringSwitch,'String','Probability threshold (%)');
set(handles.axes4string,'String','Probability distribution');
set(handles.radioRisk,'Value',1);set(handles.radioDiffusion,'Value',0);
if(handles.probathreshold>100)
handles.probathreshold=100;
set(handles.ProbabilityThresholdEdit,'String',num2str(handles.probathreshold));
end
guidata(hObject,handles);
updateDistrib(hObject,eventdata,handles);
handles=guidata(hObject);
guidata(hObject,handles);
updateAxes1(hObject,eventdata,handles);
updateAxes2(hObject,eventdata,handles);
updateAxes4(hObject,eventdata,handles);

% --- Executes on button press in radioDiffusion.
function radioDiffusion_Callback(hObject, eventdata, handles)
% hObject handle to radioDiffusion (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of radioDiffusion
set(handles.StringSwitch,'String','Radius of the balls');
set(handles.axes4string,'String','Diffusion distance distribution');
set(handles.radioRisk,'Value',0);set(handles.radioDiffusion,'Value',1);
guidata(hObject,handles);
updateDistrib(hObject,eventdata,handles);
handles=guidata(hObject);
guidata(hObject,handles);
updateAxes1(hObject,eventdata,handles);
updateAxes2(hObject,eventdata,handles);
updateAxes4(hObject,eventdata,handles);

% --- Executes during object creation, after setting all properties.
function documentList_CreateFcn(hObject, eventdata, handles)
% hObject handle to documentList (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called

% Hint: documentList 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 documentList.
function documentList_Callback(hObject, eventdata, handles)
% hObject handle to documentList (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 documentList contents as cell array
% contents{get(hObject,'Value')} returns selected item from documentList