if currentlyselecting==1;
if dimension==1;
croptoprow=selectedoriginrow2; cropbottomrow=selectedendrow2;
cropfirstcol=selectedorigincol2; croplastcol=selectedendcol2;
run save_undo;
a=a(croptoprow:cropbottomrow,cropfirstcol:croplastcol);
run computeiterations; currentiteration=0; currentlyselecting=0;
run opening_iteration; run CA_Display;
elseif dimension==2;
croptoprow=selectedoriginrow2; cropbottomrow=selectedendrow2;
cropfirstcol=selectedorigincol2; croplastcol=selectedendcol2;
cropiterationsfirst=selectedoriginiteration2; cropiterationslast=selectedenditeration2;
run save_undo;
a=a(croptoprow:cropbottomrow,cropfirstcol:croplastcol,cropiterationsfirst:cropiterationslast);
run computeiterations; currentiteration=0; currentlyselecting=0;
run opening_iteration; run CA_Display;
end;
else; errordlg('Select Area to be Cropped','Error');
end;