function PDEPlotCut(action,flag) persistent Npts; persistent plotcut_fig plotcut_orient plotcut_draw; persistent plotcut_xy plotcut_xy_label plotcut_yxmax plotcut_yxmax_label; persistent plotcut_yxmin plotcut_yxmin_label; if(nargin<1) action='initialize'; Npts=129; end if(strcmp(lower(action),'initialize')) pde_ax=findobj(allchild(0),'Tag','PDEAxes'); limits=get(pde_ax,'Xlim'); plotcut_fig=findobj(allchild(0),'Tag','plotcut_fig'); if(length(plotcut_fig)) figure(plotcut_fig); position=get(plotcut_fig,'Position'); else plotcut_fig=figure; position=get(plotcut_fig,'Position'); position=[position(1) position(2)+(1-.5)*position(4) ... .3*position(3) .5*position(4)]; end set(plotcut_fig... ...%,'Visible','off'... ,'Tag','plotcut_fig'... ,'NumberTitle','off'... ,'Name','CrossSection'... ,'resize','on'... ,'MenuBar','none'... ,'Position',position... ); plotcut_orient=... uicontrol(plotcut_fig... ,'Tag','plotcut_orient'... ,'Style','popupmenu'... ,'Units','normalized'... ,'Position',[0 .8 1 .2]... ,'String','Horizontal|Vertical'... ,'FontUnits','normalized'... ,'FontSize',.5 ... ,'CallBack','PDEPlotCut(''plotcut_orient'');'... ); plotcut_xy=... uicontrol(plotcut_fig... ,'Tag','plotcut_xy'... ,'Style','edit'... ,'Units','normalized'... ,'Position',[.5 .6 .5 .2]... ,'BackGroundColor',[1 1 1]... ,'String',num2str(0) ... ,'FontUnits','normalized'... ,'FontSize',.5 ... ,'CallBack','PDEPlotCut(''bound'',1)'... ); plotcut_xy_label=... uicontrol(plotcut_fig... ,'Tag','plotcut_xy_label'... ,'Style','text'... ,'Units','normalized'... ,'Position',[0 .6 .5 .2]... ,'String','y ='... ,'FontUnits','normalized'... ,'FontSize',.5 ... ); plotcut_yxmax=... uicontrol(plotcut_fig... ,'Tag','plotcut_yxmax'... ,'Style','edit'... ,'Units','normalized'... ,'Position',[.5 .4 .5 .2]... ,'BackGroundColor',[1 1 1]... ,'String',num2str(limits(2)) ... ,'FontUnits','normalized'... ,'FontSize',.5 ... ,'CallBack','PDEPlotCut(''bound'',2)'... ); plotcut_yxmax_label=... uicontrol(plotcut_fig... ,'Tag','plotcut_yxmax_label'... ,'Style','text'... ,'Units','normalized'... ,'Position',[0 .4 .5 .2]... ,'String','xmax ='... ,'FontUnits','normalized'... ,'FontSize',.5 ... ); plotcut_yxmin=... uicontrol(plotcut_fig... ,'Tag','plotcut_yxmin'... ,'Style','edit'... ,'Units','normalized'... ,'Position',[.5 .2 .5 .2]... ,'BackGroundColor',[1 1 1]... ,'String',num2str(limits(1)) ... ,'FontUnits','normalized'... ,'FontSize',.5 ... ,'CallBack','PDEPlotCut(''bound'',3)'... ); plotcut_yxmin_label=... uicontrol(plotcut_fig... ,'Tag','plotcut_yxmin_label'... ,'Style','text'... ,'Units','normalized'... ,'Position',[0 .2 .5 .2]... ,'String','xmin ='... ,'FontUnits','normalized'... ,'FontSize',.5 ... ); plotcut_draw=... uicontrol(plotcut_fig... ,'Tag','plotcut_draw'... ,'Style','Push'... ,'Units','normalized'... ,'Position',[0 0 1 .2]... ,'String','Draw'... ,'FontUnits','normalized'... ,'FontSize',.5 ... ,'CallBack','PDEPlotCut(''plotcut_draw'');'... ); elseif(strcmp(lower(action),'plotcut_orient')); pde_ax=findobj(allchild(0),'Tag','PDEAxes'); HorizOrVert=get(plotcut_orient,'Value'); switch(HorizOrVert) case 1 %horizontal cut coordinate is y limits=get(pde_ax,'Xlim'); set(plotcut_xy_label,'String','y ='); set(plotcut_xy,'String',num2str(0.5*sum(limits))); set(plotcut_yxmax_label,'String','xmax='); set(plotcut_yxmax,'String',num2str(limits(2))); set(plotcut_yxmin_label,'String','xmin='); set(plotcut_yxmin,'String',num2str(limits(1))); case 2 %vertical cut coordinate is x limits=get(pde_ax,'Ylim'); set(plotcut_xy_label,'String','x ='); set(plotcut_xy,'String',num2str(0.5*sum(limits))); set(plotcut_yxmax_label,'String','ymax='); set(plotcut_yxmax,'String',num2str(limits(2))); set(plotcut_yxmin_label,'String','ymin='); set(plotcut_yxmin,'String',num2str(limits(1))); end elseif(strcmp(lower(action),'bound')); pde_ax=findobj(allchild(0),'Tag','PDEAxes'); HorizOrVert=get(plotcut_orient,'Value'); switch(HorizOrVert) case 1 %horizontal cut limits=get(pde_ax,'Xlim'); case 2 %vertical cut limits=get(pde_ax,'YLim'); end switch(flag) %which edit field was just used case 1 %plotcut_xy xy=str2num(get(plotcut_xy,'String')); if(length(xy)==0); xy=0; end switch(HorizOrVert) case 1 %horizontal cut xy=min(max(xy,limits(1)),limits(2)); case 2 %vertical cut xy=min(max(xy,limits(1)),limits(2)); end set(plotcut_xy,'String',num2str(xy)); case 2 %plotcut_yxmax yxmax=str2num(get(plotcut_yxmax,'String')); if(length(yxmax)==0); yxmax=0; end switch(HorizOrVert) case 1 %horizontal cut yxmax=min(max(yxmax,limits(1)),limits(2)); case 2 %vertical cut yxmax=min(max(yxmax,limits(1)),limits(2)); end set(plotcut_yxmax,'String',num2str(yxmax)); case 3 %plotcut_yxmin yxmin=str2num(get(plotcut_yxmin,'String')); if(length(yxmin)==0); yxmin=0; end switch(HorizOrVert) case 1 %horizontal cut yxmin=min(max(yxmin,limits(1)),limits(2)); case 2 %vertical cut yxmin=min(max(yxmin,limits(1)),limits(2)); end set(plotcut_yxmin,'String',num2str(yxmin)); end elseif(strcmp(lower(action),'plotcut_draw')) %just in case user changed bounds since cut selected PDEPlotCut('bound',1); PDEPlotCut('bound',2); PDEPlotCut('bound',3); %find the current axes... old one might have died pde_ax=findobj(allchild(0),'Tag','PDEAxes'); h=findobj(get(pde_ax,'Children'),'Type','patch'); for i=1:length(h) if(length(get(h(i),'ZData'))) pde_ax_points=h(i); break end end HorizOrVert=get(plotcut_orient,'Value'); %get interpolation points from cut line switch(HorizOrVert) case 1 %horizontal cut yi=str2num(get(plotcut_xy,'String')); xmin=str2num(get(plotcut_yxmin,'String')); xmax=str2num(get(plotcut_yxmax,'String')); if(xmax=ysort(:,2)); x2=zeros([N 1]); z2=x2; yada=(yi-ysort(i,2))./(ysort(i,3)-ysort(i,2)); x2(i)=yada.*(xsort(i,3)-xsort(i,2))+xsort(i,2); z2(i)=yada.*(zsort(i,3)-zsort(i,2))+zsort(i,2); %part of time, the line passes through the triangle edge %connecting the points with the triangle's middle and minimum %value i=find(yi