Bt ac9.m
Revision as of 15:55, 2 August 2010 by 128.111.101.185 (talk) (Created page with '<pre> % command file for matlab bottom top determination: Daniel C. Konnoff % 10/08/92 % modified: JBU Oct 97 - fits new 1997 ac9 processing scheme % - yadda yadda yadda …')
% command file for matlab bottom top determination: Daniel C. Konnoff
% 10/08/92
% modified: JBU Oct 97 - fits new 1997 ac9 processing scheme
% - yadda yadda yadda
% modified: SRW 98 - now a function that returns [d]
function [d]=bt_ac9(mat_in);
clf;
% set graph geometry
set (gcf,'units','inches', 'pos',[2 1 9 5])
% declare variables
u=[]; % holds the points
d=[]; % holds the index's only
cast=0;
plot(mat_in(:,1),mat_in(:,2),'.');grid;
while(1)
cast=cast+1
which=['Selecting points for cast: ',num2str(cast)];
% first point
disp('select the first region')
title(which);
[x,y]=ginput(2);
% zoom to start point of the cast
if y(1)<y(2)
if x(1)<x(2)
axis([x(1),x(2),y(1),y(2)])
else
axis([x(2),x(1),y(1),y(2)])
end
else
if x(1)<x(2)
axis([x(1),x(2),y(2),y(1)])
else
axis([x(2),x(1),y(2),y(1)])
end % end if
end % end if
% pretty the graph
hold on
plot(mat_in(:,1),mat_in(:,2),'ro'); grid; title(which);
plot([x(1), x(2)], [0, 0], 'g-.');
hold off;
% find specific start point
disp('click on start of cast')
[x,y]=ginput(1);
% add the points to cast_id array
u=[u;x,y];
% last point
plot(mat_in(:,1),mat_in(:,2),'.');grid; title(which);
hold on;
%d=ceil(u(:,1))
d=[];
for id=1:size(u,1),
dd=find(mat_in(:,1)<u(id,1));%___________________________
d=[d; dd(end)];%-----------------------------------------
end
for ip=1:2:size(d,1),
plot(u(:,1),u(:,2),'ro');
end
% $$$ plot(mat_in(d(1):d(end),1),...
% $$$ mat_in(d(1):d(end),2),'g',u(:,1),u(:,2),'ro');
disp('select the end region')
[x,y]=ginput(2);
% zoom to end point of the cast
if y(1)<y(2)
if x(1)<x(2)
axis([x(1),x(2),y(1),y(2)])
else
axis([x(2),x(1),y(1),y(2)])
end
else
if x(1)<x(2)
axis([x(1),x(2),y(2),y(1)])
else
axis([x(2),x(1),y(2),y(1)])
end % end if
end % end if
% pretty the graph
hold on
plot(mat_in(:,1),mat_in(:,2),'ro');grid; title(which);
plot([x(1), x(2)], [0, 0], 'g-.');
hold off;
% find specific end point
disp('click on end of cast')
[x,y]=ginput(1);
% add the points to cast_id array
u=[u;x,y];
% are we done yet?
axis('auto');
plot(mat_in(:,1),mat_in(:,2),'.');grid; title(which);
hold on;
%d=ceil(u(:,1))
d=[];
for id=1:size(u,1),
dd=find(mat_in(:,1)<u(id,1));
d=[d; dd(end)];
end
for ip=1:2:size(d,1),
plot(mat_in(d(ip):d(ip+1),1),...
mat_in(d(ip):d(ip+1),2),'g',u(:,1),u(:,2),'ro');
end
% $$$ plot(mat_in(d(1):d(end),1),...
% $$$ mat_in(d(1):d(end),2),'g',u(:,1),u(:,2),'ro');
title('Selected points'); grid;
disp(' ');
%disp('Want to save these points?');
%done=input('y or n: ','s');
%disp(' ')
% $$$ if (done=='y'|done=='Y')
% $$$ d(1,1)=ceil(u(1,1)); % copy index's to d vector
% $$$ d(2,1)=floor(u(2,1));
% $$$ d=[d, mat_in(d,1), -mat_in(d,2)];
% $$$ disp('Your final cast_id array:')
% $$$ disp(d)
% $$$ save bt.pts d /ascii;
% $$$ else
% $$$ disp('castID not saved, re-run by typing "bt_ac9" at the prompt');
% $$$ end % end if-else
ButtonName=questdlg('Save these points to CastID matrix?',...
'','Yes','No','No');
switch ButtonName,
case 'Yes'
%d=ceil(u(:,1));
d=[];
for id=1:size(u,1),
dd=find(mat_in(:,1)<u(id,1));
d=[d; dd(end)];
end
%d(1,1)=ceil(u(1,1)) % copy index's to d vector
%d(2,1)=floor(u(2,1))
case 'No'
disp('Points not saved to castID, ');
for ip=1:2:size(d,1),
plot(mat_in(d(ip):d(ip+1),1),...
mat_in(d(ip):d(ip+1),2));
end
u(length(u)-1:length(u),:)=[];
%d=ceil(u(:,1));
d=[];
for id=1:size(u,1),
dd=find(mat_in(:,1)<u(id,1));
d=[d; dd(end)];
end
end % switch
ButtonName=questdlg('Pick points for another cast?',...
'','Yes','No','No');
switch ButtonName,
case 'Yes'
case 'No'
if ~isempty(d),
d=[d, mat_in(d,1), -mat_in(d,2)];
disp('Your final cast_id array:')
disp(d)
%cd(pb) %--------------------------
save bt.pts d /ascii;
% cd ..
end
return;
end % switch
end % while
return