Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
function flowsimple
xrange = [-5 5];
yrange = [-5 5];
% xrange = [0 4];
% yrange = [0 4];
rngx = xrange(2) - xrange(1);
rngy = yrange(2) - yrange(1);
[X,Y] = meshgrid(xrange(1):0.1:xrange(2), yrange(1):0.1:yrange(2));
smallarrow = 0;
[x,y] = f5(X,Y);
clf
figure(1)
for xloop = 1:10
xs = xrange(1) +xloop*rngx/10;
for yloop = 1:10
ys = yrange(1) +yloop*rngy/10;
streamline(X,Y,x,y,xs,ys)
end
end
hold on
[XQ,YQ] = meshgrid(xrange(1):1:xrange(2),yrange(1):1:yrange(2));
smallarrow = 0;
[xq,yq] = f5(XQ,YQ);
quiver(XQ,YQ,xq,yq,.2,'r','filled')
hold off
axis([xrange(1) xrange(2) yrange(1) yrange(2)])
set(gcf,'Color','White')
function [x,y] = f5(X,Y)
% xtmp = X*(1-X^2) - Y;
% ytmp = X;
% xtmp = Y; % Double well
% ytmp = -0.5*Y + X - X.^3;
% xtmp = X*(1-2*X+Y);
% ytmp = Y*(1+X-Y);
% xtmp = X.*(1-Y.^3); % testing dsge
% ytmp = Y.*(2.5-X);
% xtmp = X.*Y + 1 - 0.5*X;
% ytmp = Y.*(2 - X);
xtmp = X.*(3-Y); % Rabbit sheep
ytmp = Y.*(2-X);
% xtmp = Y;
% ytmp = -X - 0.1*exp(-abs(X)/1)*X.^2;
% c = 1; % Medio
% xtmp = -Y + X.*(c - Y.^2);
% ytmp = X + 1;
% xtmp = X.*(1-2*X+Y);
% ytmp = Y.*(0.5 + 0.5*X - Y);
% xtmp = Y+0.75*X;
% ytmp = X.^3-Y-X;
% xtmp =X.*(2-X-Y);
% ytmp = X-Y;
% xtmp = X.*(X-Y);
% ytmp = Y.*(2*X-Y);
% a = 2; b = 2; % Inward spiral
% xtmp = Y - a*X;
% ytmp = -X - b*Y;
% xtmp = -X.^2-Y;
% ytmp = X;
% xtmp = X.^2 - Y;
% ytmp = X - Y;
%x = X.*(3-X-2*Y);
%y = Y.*(2-X-Y);
nrm = sqrt(xtmp.^2 + ytmp.^2);
if smallarrow == 1
x = xtmp./nrm;
y = ytmp./nrm;
else
x = xtmp;
y = ytmp;
end
end % end f5
end % end flowsimple