조회 수: 3 (최근 30일)
Tsogerdene 2011년 8월 3일
I just wondering that why this code working wrong. Please help me! I can't manipulate the ODE function.
options=odeset('RelTol',10^-4);
[T,Y]=ode23('turshilt23',[0 300],[0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5],options);
plot(T,Y);
function dy=turshilt23(t,y,flag)
%here is some code
if(k==0)
y(1)=y(1)/2;
end
dy(1)=mu*y(1)*(1-(y(1)/m_max));
%here is some code
end

댓글을 달려면 로그인하십시오.

### 답변 (3개)

Arnaud Miege 2011년 8월 3일
Also, it seems that in your function turshilt23, you haven't defined what k, mu or m_max are. Finally you compute dy(1), but you call the ode solver with an initial condition vector of length 9. You need to compute dy(2), dy(3), ... dy(9) in your function as well.
Have a look at the documentation for the ode solvers, there are various examples you can inspire yourself from.
HTH,
Arnaud
##### 댓글 수: 0이전 댓글 -2개 표시이전 댓글 -2개 숨기기

댓글을 달려면 로그인하십시오.

Tsogerdene 2011년 8월 3일
function dy=turshilt23(t,y,flag)
global Global_CycB1;
global Global_CycB2;
global k;
global y_1;
dy=zeros(9,1);
% size of protein
mu=0.005;
m_max=10;
dy(1)=mu*y(1)*(1-(y(1)/m_max));
if Global_CycB2 >=0.099 & Global_CycB2<0.1
if Global_CycB2>Global_CycB1
y(1)=y(1)*(1/2);
end
end
%CycBT
k1=0.04;
k2_1=0.04;
k2_2=1;
k2_3=1;
dy(2)=k1-(k2_1+k2_2*y(3)+k2_3*y(5))*y(2);
Keq=1000;
beta=y(2)+y(7)+Keq^(-1);
Trimer=(2*y(2)*y(7))/(beta+(beta^2-4*y(2)*y(7))^(1/2));
CycB=y(2)-Trimer;
Global_CycB1=Global_CycB2;
Global_CycB2=CycB;
%Cdh1
k3_1=1;
k3_2=10;
k4_1=2;
k4=35;
J3=0.04;
J4=0.04;
dy(3)= (((k3_1+k3_2*y(5))*(1-y(3)))/(J3+1-y(3)))-(((k4*y(1)*CycB+k4_1*y(8))*y(3))/(J4+y(3)));
%Cdc20T
k5_1=0.005;
k5_2=0.2;
k6=0.1;
J5=0.3;
n=4;
dy(4)= k5_1+k5_2*((y(1)*CycB)^n/(J5^n+(y(1)*CycB)^n))-k6*y(4);
%Cdc20A
k6=0.1;
k7=1;
k8=0.5;
J7=1*(10^(-3));
J8=1*(10^(-3));
%IEP
k9=0.1;
k10=0.02;
dy(6)= k9*y(1)*CycB*(1-y(6))-k10*y(6);
%CKI
k11=1;
k12_1=0.2;
k12_2=50;
k12_3=100;
dy(7) = k11-(k12_1+k12_2*y(8) +k12_3*y(1)*CycB)*y(7);
%SK
k13_1=0;
k13_2=1;
k14=1;
dy(8)= k13_1+k13_2*y(9)-k14*y(8);
%TF
k15_1=1.5;
k15_2=0.05;
k16_1=1;
k16_2=3;
J15=0.01;
J16=0.01;
dy(9)= (((k15_1*y(1)+k15_2*y(8))*(1-y(9)))/(J15+1-y(9)))-(((k16_1+k16_2*y(1)*CycB)*y(9))/(J16+y(9)));
##### 댓글 수: 2없음 표시없음 숨기기
Arnaud Miege 2011년 8월 3일
It works for me. What error message do you get?
* Your function is a function of t, y and flag but t and flag are not used. Consider replacing those with ~
* Your function defines k and y_1 as global variables, but those aren't used in the function. You can remove those two lines.
The only changes I made were therefore:
function dy=turshilt23(~,y,~)
global Global_CycB1;
global Global_CycB2;
% global k;
% global y_1;
I used 0.1 for the other two global variables Global_CycB1 and Global_CycB2. The solver solved OK.
Walter Roberson 2011년 8월 3일
Note: Using ~ in that way is not available in 2008 and earlier.

댓글을 달려면 로그인하십시오.

Tsogerdene 2011년 8월 8일
Thank you for helping. I just asking that y(1)=y(1)*(1/2)? I would like to divide actual value of y(1) when some conditions are satisfied. I used y(1)=y(1)*(1/2), but nothing is changed.
##### 댓글 수: 3이전 댓글 1개 표시이전 댓글 1개 숨기기
Tsogerdene 2011년 8월 8일
Oh I see. Thank you very much!. I understood that.
Walter Roberson 2011년 8월 8일
Typo correction: I meant for "future iterations"

댓글을 달려면 로그인하십시오.

### 카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by