How to get the output for the following code into the workspace?
조회 수: 1 (최근 30일)
이전 댓글 표시
My code is as follows:
function H = newmain
global b1 b2 b3;
b1=0;
b2=2.0;
b3=0.33;
options=odeset('InitialStep', 0.01, 'MaxStep', 0.01, 'RelTol', 10., 'AbsTol',10.);
[t2,y2]=ode45(@equation,[0:0.05:0.1],[1 2 0], options);
H = [t2 y2]
end
function dy=equation(t,y)
global b1 b2 b3
dy=zeros(3,1);
b1=b1+1-exp(-b3)
b2=b1-y(1)
b3=b1+b2+y(2)
dy(1)=-b1*y(1);
dy(2)=b3*y(1)+b2*y(2);
dy(3)=sqrt(b1)+y(1)+y(3);
end
How can directly get the values of b1 b2 b3 y1 y2 y3 at the same time instant in the workspace?
Thanks!
댓글 수: 0
답변 (1개)
Azzi Abdelmalek
2012년 10월 19일
function dy=equation(t,y)
global c b1 b2 b3 y1 y2 y3
y1=y(1);y2=y(2);y3=y(3);
dy=zeros(3,1);
b1=b1+1-exp(-b3)
b2=b1-y(1)
b3=b1+b2+y(2)
dy(1)=-b1*y(1);
dy(2)=b3*y(1)+b2*y(2);
dy(3)=sqrt(b1)+y(1)+y(3);
c=[c; b1 b2 b3 y1 y2 y3]
add in your main program
global c b1 b2 b3 y1 y2 y3
y1=0;y2=0;y3=0;c=[];
댓글 수: 2
참고 항목
카테고리
Help Center 및 File Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!