Issue in term mismatch after finding roots

1 回表示 (過去 30 日間)
Melissa
Melissa 2014 年 12 月 17 日
回答済み: Roger Stafford 2014 年 12 月 17 日
I aim having a mismatch error in the following code. The term1a works fine but I get no output from term1b, which I believe is causing my mismatch error. "In an assignment A(I) = B, the number of elements in B and I must be the same" referring to CB1(t)=Cb
while n<22
f=@(qn) tan(qn)-((3*qn./(3+alpha*(qn.^2))));
r= fzero(f,pi/2*[n n+2].*(1+100*eps*[1 -1]));
%term1=(6*alpha*(1+alpha)*exp(-Dall*(r.^2)*(t/(rS.^2))))/(9+9*(r.^2)*(alpha.^2));
term1a=(6*alpha*(1+alpha)*exp(-Dall1*(r.^2)*(t/(rS.^2))))/(9+9*(r.^2)*(alpha.^2))
term1b=((rS+.01)/rS)*(sin(qn.*rS./(rS+.01))/sin(qn))
term2=term2+term1a.*term1b;
n=n+2;
end
Cb1=(cAi/(1+alpha))*(1-term2);
CB1(t)=Cb1;

採用された回答

Roger Stafford
Roger Stafford 2014 年 12 月 17 日
In the expression for 'term1b' you use the variable 'qn'. However, that appears to be the dummy argument for your function 'f'. Perhaps you need to replace that 'qn' with the root, 'r'.
Also you need to be sure that the variable 't' is a positive integer if it is to be used as an index in "CB1(t)=Cb1;".

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAnalysis, Benchmarking, and Verification についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by