I get error in unrecognized function or variable 'T'.
조회 수: 2 (최근 30일)
이전 댓글 표시
Hello, I get error in my code. I want to make my dtab function depends on time but i get error "unrecognized function or variable T"
clc;clear;
%parameter
delta=50;
gamma=75;
K1=10^-4;
K2=5*10^-4;
K3=10^-3;
K4=5*10^-3;
K5=10^-2;
K6=5*10^-2;
Ko=0.1;
n=6;
Oa=10;
Pa=100;
mu_1=10^-3;
mu_2=10^-3;
mu_3=10^-3;
mu_4=10^-3;
mu_5=10^-3;
mu_6=10^-3;
mu_o=10^-4;
mu_p= 10^-5;
%input for time
t(1)=0;
dt=0.01; %time interval
t=0:dt:100; %time span
%component drugs
Abi = 10^-6;
lambdaN = 8*10^-4;
lambdaA = 8*10^-4;
daboM = 2*10^-3;
dabom = 10^-2; %clearance rate by macrophages
makrofag1 = 0;
makrofag2 = 0;
mikro1 = 0.02;
mikro2 = 0.02;
teta = 0.9;
h = 10;
Kaob = 7*10^-3;
AoB = 10^-8;
dtdab = Abi*(dt*(0.14*1.9*10^-4*exp(-1.9*10^-4*t)))+ (lambdaN*1)+(lambdaA*1)-(dabom*(makrofag1+(teta*makrofag2))+daboM*(mikro1+(teta*mikro2))*(1+h))*(AoB/(AoB+Kaob));
%initial condition with drugs
M13(1)=10;
M23(1)=0;
M33(1)=0;
M43(1)=0;
M53(1)=0;
M63(1)=0;
O3(1)=0;
P3(1)=0;
%empty array with drugs
M13=zeros(length(t)+1,1); %empty array for M1
M23=zeros(length(t)+1,1); %empty array for M2
M33=zeros(length(t)+1,1); %empty array for M3
M43=zeros(length(t)+1,1); %empty array for M4
M53=zeros(length(t)+1,1); %empty array for M5
M63=zeros(length(t)+1,1); %empty array for M6
O3=zeros(length(t)+1,1); %empty array for O
P3=zeros(length(t)+1,1); %empty array for P
sumter2=K2*M23+K3*M33+K4*M43+K5*M53;
for j = 1:length(t)
%with drugs
T(j+1)=T(j)+dt;
M13(j+1) = M13(j)+1./(1+exp(-T(j)));
M13(j+1) = M13(j)+(dt*(delta*M13(j+1)*(1-(M13(j+1)/gamma))-2*K1*M13(j+1)*M13(j+1)-M13(j+1)*sumter2(j+1))-((Oa-n)*K6*M13(j+1)*M63(j+1))-((Pa-Oa)*Ko*M13(j+1)*O3(j+1))-(mu_1*M13(j+1)));
M23(j+1) = M23(j)+(dt*(K1*M13(j)*M13(j)-K2*M13(j)*M23(j))-(mu_2*M23(j+1))-dtmakro1-dtmakro2-dtdab);
M33(j+1) = M33(j)+(dt*(K2*M13(j)*M23(j)-K3*M13(j)*M33(j))-mu_3*M33(j));
M43(j+1) = M43(j)+(dt*(K3*M13(j)*M33(j)-K4*M13(j)*M43(j))-mu_4*M43(j));
M53(j+1) = M53(j)+(dt*(K4*M13(j)*M43(j)-K5*M13(j)*M53(j))-mu_5*M53(j));
M63(j+1) = M63(j)+(dt*(K5*M13(j)*M53(j)-K6*M13(j)*M63(j))-mu_6*M63(j));
O3(j+1) = O3(j)+(dt*(K6*M13(j)*M63(j)-Ko*M13(j)*O3(j)-mu_o*O3(j)));
P3(j+1) = P3(j)+(dt*(Ko*M13(j)*O3(j)-mu_p*P3(j)));
end
figure
plot(T,M13,'k','Linewidth',3)
legend ('M1 with drugs');
xticks ([10 20 30 40 50 60 70 80 90 100])
xlabel('time (days)')
ylabel('M1 (gr/ml)')
figure
plot(T,M23,'k','Linewidth',3)
legend ('M2 with drugs');
xticks ([10 20 30 40 50 60 70 80 90 100])
yticks ([ 0 2 4 6 8 10 12 14 16])
xlabel('time (days)')
ylabel('M2 (gr/ml)')
figure
plot(T,M33,'k','Linewidth',3)
legend ('M3 with drugs');
xticks ([10 20 30 40 50 60 70 80 90 100])
yticks ([0 0.5 1 1.5 2 2.5 3 3.5])
xlabel('time (days)')
ylabel('M3 (gr/ml)')
figure
plot(T,M43,'k','Linewidth',3)
legend ('M4 with drugs');
xticks ([10 20 30 40 50 60 70 80 90 100])
yticks ([0 0.1 0.2 0.3 0.4 0.5])
xlabel('time (days)')
ylabel('M4 (gr/ml)')
figure
plot(T,M53,'k','Linewidth',3)
legend ('M5 with drugs');
xticks ([10 20 30 40 50 60 70 80 90 100])
yticks ([0 0.05 0.1 0.15 0.2])
xlabel('time (days)')
ylabel('M5 (gr/ml)')
figure
plot(T,M63,'k','Linewidth',3)
legend ('M6 with drugs');
xticks ([10 20 30 40 50 60 70 80 90 100])
yticks ([0 0.005 0.01 0.015 0.02 0.025 0.03 0.035 0.04 0.045])
xlabel('time (days)')
ylabel('M6 (gr/ml)')
figure
plot(T,O3,'k','Linewidth',3)
legend ('O with drugs');
xticks ([10 20 30 40 50 60 70 80 90 100])
yticks ([0 0.005 0.01 0.015 0.02])
xlabel('time (days)')
ylabel('O (gr/ml)')
figure
plot(T,P3,'k','Linewidth',3)
legend ('P with microglia', 'P without microglia','P with drugs');
xticks ([10 20 30 40 50 60 70 80 90 100])
yticks ([0 2 4 6 8 10 12])
xlabel('time (days)')
ylabel('P (gr/ml)')
댓글 수: 0
채택된 답변
Torsten
2023년 10월 2일
I changed the bold parts below:
T = t;
for j = 1:length(t)
%with drugs
T(j+1)=T(j)+dt;
M13(j+1) = M13(j)+1./(1+exp(-T(j)));
M13(j+1) = M13(j)+(dt*(delta*M13(j+1)*(1-(M13(j+1)/gamma))-2*K1*M13(j+1)*M13(j+1)-M13(j+1)*sumter2(j+1))-((Oa-n)*K6*M13(j+1)*M63(j+1))-((Pa-Oa)*Ko*M13(j+1)*O3(j+1))-(mu_1*M13(j+1)));
M23(j+1) = M23(j)+(dt*(K1*M13(j)*M13(j)-K2*M13(j)*M23(j))-(mu_2*M23(j+1))-dt*makrofag1-dt*makrofag2-dtdab(j));
M33(j+1) = M33(j)+(dt*(K2*M13(j)*M23(j)-K3*M13(j)*M33(j))-mu_3*M33(j));
M43(j+1) = M43(j)+(dt*(K3*M13(j)*M33(j)-K4*M13(j)*M43(j))-mu_4*M43(j));
M53(j+1) = M53(j)+(dt*(K4*M13(j)*M43(j)-K5*M13(j)*M53(j))-mu_5*M53(j));
M63(j+1) = M63(j)+(dt*(K5*M13(j)*M53(j)-K6*M13(j)*M63(j))-mu_6*M63(j));
O3(j+1) = O3(j)+(dt*(K6*M13(j)*M63(j)-Ko*M13(j)*O3(j)-mu_o*O3(j)));
P3(j+1) = P3(j)+(dt*(Ko*M13(j)*O3(j)-mu_p*P3(j)));
end
and the code works.
Of course I don't now if this is what you want.
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Function Creation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!