Issue in term mismatch after finding roots

1 次查看(过去 30 天)
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 CenterFile Exchange 中查找有关 Analysis, Benchmarking, and Verification 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by