Using find command to find bifurcation points
조회 수: 23 (최근 30일)
이전 댓글 표시
I have code which plots a graph showing the levels of Notch and Delta in a pair of cells. The graph is a bifurcation diagram with 2 bifurcation points. After plotting, I have attempted to find the 2 values of 'a' where the bifurcations happen. I have tried using the find command but only receive empty vectors when I run the code. Function file is at the end of the code.
% Specify initial conditions
dinit=[0 1];
ninit=[1 0];
initialconditions=[dinit; ninit]';
% Set values of a
a=logspace(-8,2,200);
for i=1:numel(a)
% Apply ode45
[t,y]=ode45(@(t,y)twocellfunct(t,y,a(i)),[0 200],initialconditions);
% Calculate maximum value of Notch in cells 1 and 2
mx=max([y(end,3), y(end,4)]);
% Calculate minimum value of Notch in cells 1 and 2
mn=min([y(end,3), y(end,4)]);
% Storing the max/min values of notch for each a
M(:,i)=[mx mn]';
end
% Plot
semilogx(a,M(1,:),'r');
hold on
semilogx(a,M(2,:),'b');
xlabel('a');
ylabel('notch level');
y=ylabel('notch level', 'rot', 90);
set(y, 'Units', 'Normalized', 'Position', [-0.07, 0.5, 0]);
a1=find(abs(M(1,:)-M(2,:))<eps,1,'first');
a2=find(abs(M(1,:)-M(2,:))<eps,1,'last');
function l = twocellfunct(t,y,a)
% Specifying parameters
b=100;
v=1;
k=2;
h=2;
% RHS functions
f=@(x)(x.^k./(a+x.^k));
g=@(x)(1./(1+b.*x.^h));
l = [v.*(g(y(3))-y(1)); v.*(g(y(4))-y(2)); f(y(2))-y(3); f(y(1))-y(4)];
end
댓글 수: 3
the cyclist
2019년 11월 18일
Without being able to run your code, I speculated that eps is too tight a tolerance. Have you tried making that larger?
채택된 답변
the cyclist
2019년 11월 18일
편집: the cyclist
2019년 11월 18일
Here is a loglog plot of the difference between M(1,:) and M(2,:).
I think what you are actually trying to do is find the first and last points where the difference is larger than some tolerance, not smaller. That's the bifurcation.
It's an inexact science, but the following tolerance will get close. You might be able to refine the estimate with additional rules.
tol = 5.e-3;
a1=find(abs(M(1,:)-M(2,:))>tol,1,'first');
a2=find(abs(M(1,:)-M(2,:))>tol,1,'last');
댓글 수: 3
the cyclist
2019년 11월 18일
a1 and a2 are the indices into a, not the values. You'll get what you want from
a(a1)
a(a2)
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!