% like the built-in PV-Wave or IDL function of the same name; Steve Mann % % Examples: g = profiles(A,L); % interactive profile of length L % g = profiles(A); % interactive profile of default length = 500 % g = profiles(A,256,8);% interactive profile length 256 on figure 8 % [g,x,y] = profiles(A) % keeps track from where the profile was taken % figure % x and y are 1 by 2 x=[begx, endx] % tvs(A) % line(x,y) % puts back this information on another plot function [profile,locationx,locationy]=something(A,L,figure_number) if nargin<3 figure_number=NaN; end%if if nargin<2 L=500; % nice number for plotting on typical plotwindow screen size end%if if isnan(figure_number) figure else%if figure(figure_number) end%if tvs(A) % holdstatus=ishold; % hold on disp('profiles: click on FIRST point (press any mouse button)') [x1,y1,button1]=ginput(1); disp(sprintf('profiles: x1 = %g, y1 = %g (button%g)',x1,y1,button1)) % plot(x1,y1,'y+') point(x1,y1,'x') % note point doesnt need hold on; lower level and faster % user really needs this feedback since it is very slow and mouse sometimes bad disp('profiles: now click on SECOND point (any mouse button)') [x2,y2,button2]=ginput(1); disp(sprintf('profiles: x2 = %g, y2 = %g (button%g)',x2,y2,button2)) %plotting twice too slow so plot all pts together 1 command %plot(x1,y1,'o') % ginput kills previous point; need to redraw; I use o for old %plot(x2,y2,'+') % draw new point as well %plot(x1,y1,'yo',x2,y2,'y+') %better to plot the whole line %plot([x1,x2],[y1,y2]) point(x1,y1,'x') % need to redraw first pt because ginput+line clears it point(x2,y2,'x') line([x1,x2],[y1,y2]) % note line doesn't need hold on; lower level and faster % exit in same hold status as entered % if holdstatus % hold on % else%if % hold off % end%if x=linspace(x1,x2,L); y=linspace(y1,y2,L); profile=NaN*ones(L,1); % allocate for l=1:L profile(l)=A(y(l),x(l)); end%for % figure(gcf+1) % plot(profile) % figure(gcf-1) locationx=[x1,x2]; locationy=[y1,y2];