function p11_tst(tstId) % CEE 2016 % April 2016, J. Gaspar if nargin<1 tstId= [0 1 2]; %2; end if length(tstId)>1 for i=1:length(tstId), p11_tst(tstId(i)); drawnow; end return end switch tstId case 0, tst1_v0 case 1, tst1_v1 case 2, tst2 otherwise error('inv tstId') end function tst1_v0 [n,p]= meshgrid(0:.1:1.1, 0:.1:2.1); n= n(:); p=p(:); % the nonlinear SYSTEM: u= n.*(1-n-p); v= p.*(.5-p/4 -3*n/4); % clear vectors over p=2-2*n % as they are large and therefore hide other info if 1, %0 ind= find(p>2-2*n); u(ind)=0; v(ind)=0; end figure(300); clf; hold on set(gcf,'position', [21 330 478 365]) quiver(n,p,u,v) axis equal np0= [0 0; 0 2; 1 0; .5 .5]; plot(np0(:,1), np0(:,2), 'or') xlabel('N'); ylabel('P'); return function tst1_v1 %[n,p]= meshgrid(0:.1:1.1, 0:.1:2.1); [n,p]= meshgrid(0.45:.01:.55, 0.45:.01:.55); % zoom one eq point sz= size(n); n= n(:); p=p(:); % the nonlinear SYSTEM: u= n.*(1-n-p); v= p.*(.5-p/4 -3*n/4); figure(301); clf; hold on set(gcf,'position', [7 39 352 255]) g= 1e3; quiver(n,p,g*u,g*v) xlabel('N'); ylabel('P'); axis tight axis equal figure(302); clf; hold on set(gcf,'position', [374 38 416 258]) uv2= reshape(sqrt(u.*u+v.*v), sz); %mask= (uv2>max(uv2(:,1))); uv2(mask)=max(uv2(:,1)); %0; %imshow(uint8(inorm(uv2))) %imagesc(uv2); axis xy mesh(uv2) view(24, 44) xlabel('N'); ylabel('P'); zlabel('deriv vect norm') return function tst2 p11_sh_np(0,0) p11_sh_np(0,2) p11_sh_np(1,0) p11_sh_np(.5,.5)