作者ANUBISANKH (Pourquoi?)
看板NTUNL
标题[爆炸] 昨天讲的 bifurcation matlab file
时间Sat Sep 30 20:04:53 2006
(1) 先开一个 .m file 建立 function (他会直接要求你存成 hysterisis.m):
function dydt=hysterisis(t,x,u)
global u;
dydt=[u*x+x^3-x^5];
(2) 建立执行档,一样开一个 .m file:
clear all;
global u;
for i=1:100
% setting the range of parameter "u"
u=0.01*(i-50);
% different initial conditions
x0=[2.15];
y0=[0.04];
a0=[-2.15];
b0=[-0.04];
% solving odes by ode45
[t,x]=ode45(@hysterisis,0:0.1:10,x0);
[t,y]=ode45(@hysterisis,0:0.1:10,y0);
[t,a]=ode45(@hysterisis,0:0.1:10,a0);
[t,b]=ode45(@hysterisis,0:0.1:10,b0);
% defining the 100th step calculation of x as x*
X(i)=x(100);
Y(i)=y(100);
A(i)=a(100);
B(i)=b(100);
% redefining the parameter "u" as "u(i)"
U(i)=u;
end
subplot(2,2,1),plot(U,X)
ylabel('x*')
xlabel('u')
subplot(2,2,2),plot(U,Y)
ylabel('x*')
xlabel('u')
subplot(2,2,3),plot(U,A)
ylabel('x*')
xlabel('u')
subplot(2,2,4),plot(U,B)
ylabel('x*')
xlabel('u')
--
先这样啦,试试看就好。
--
" Morning's going past us and heading your way, my friend.
You give it a chance, morning's going to bring you the
reason you need, some purpose, because that's what the
morning does."
==== Dean Knootz, SOLE SURVIOVOR ====
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 220.136.91.18