Array indices must be positive integers or logical values.
古いコメントを表示
Hello,
I have been trying to run the code below. I have gotten everything to work for lines 14 & 15, but I cannot figure out what is wrong with line 16 (NC_t). I receieve the follow error upon running the program:
"Array indices must be positive integers or logical values."
May someone help explain where something is going wrong? I would greatly appreciate the help.
Thanks!
clc;
clear all;
n=51;
NA_0=100; % Initial Condition for N1
NB_0=0; % Initial Condition for N2
NC_0=0; % Inital Condition for N2
Lambda_0=0.3429; % Decay Constant for N_1 (hr^-1)
Lambda_1=.076154; % Decay Constant for N_2 (hr^-1)
t(1)=0; % (hr)
dt=1; % (hr)
for i=1:n
t(i)=i*dt-dt;
NA_t(i)=NA_0*exp(-1*Lambda_0*t(i));
NB_t(i)=NB_0*exp(-1*Lambda_1*t(i))+(Lambda_0*NA_0)/(Lambda_1-Lambda_0)*(exp(-1*Lambda_0*t(i))-exp(-1*Lambda_1*t(i)));
NC_t(i)=NC_0+NB_0*(1-exp(-1*Lambda_1*t(i)))+(NA_0/(Lambda_1-Lambda_0))*(Lambda_1(1-exp(-1*Lambda_0*t(i)))-Lambda_0(1-exp(-1*Lambda_1*t(i))));
end
plot(t,NB_t,t,NA_t);
2 件のコメント
John D'Errico
2021 年 10 月 2 日
When you show a PICTURE of code, what happens is now we cannot even paste in your code nd execute it for ourselves. Everything there was purely text, so trivial to paste in directly. But now we need to read small, fuzzy pictures of text, to try to find the error in your code.
Why would you deliberately make it more difficult for someone to help you?
Joseph Wunschel
2021 年 10 月 2 日
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で MATLAB についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!