Issue in term mismatch after finding roots
2 views (last 30 days)
Show older comments
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;
0 Comments
Accepted Answer
Roger Stafford
on 17 Dec 2014
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 Comments
More Answers (0)
See Also
Categories
Find more on Analysis, Benchmarking, and Verification in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!