usage of syms in for loop?

2 views (last 30 days)
abdul haakim mohammed
abdul haakim mohammed on 25 Jan 2016
Commented: Walter Roberson on 25 Jan 2016
for i=1:15
bx=zeros(15,1)
dx=zeros(15,1)
syms b d
VNX(i) = ((Av(i)*Fy(i)*0.8*d)/S(i))+(0.16*sqrt(Fck(i))*b*d)+((0.48*P(i))/sqrt(Fck(i)))
assume(b>0)
assume(d>0)
sol = solve([VNX], [b,d]);
bx(i) = sol.b
dx(i) = sol.d
end

Answers (1)

Walter Roberson
Walter Roberson on 25 Jan 2016
Edited: Walter Roberson on 25 Jan 2016
You did not ask a question. But meanwhile you need to fix the problems I described for your other question http://uk.mathworks.com/matlabcentral/answers/265042-how-to-optimize-this-solution#answer_207291
By the way, you do not want
bx=zeros(15,1)
dx=zeros(15,1)
inside your "for" loop, as that is going to reinitialize all of bx and dx each iteration of "i", overwriting all the answers you got before.
  2 Comments
abdul haakim mohammed
abdul haakim mohammed on 25 Jan 2016
i want to use the for loop for syms but i am not ale to do so it is giving me an error that says
"The following error occurred converting from sym to double: Error using symengine (line 58) DOUBLE cannot convert the input expression into a double array. If the input expression contains a symbolic variable, use VPA."
Walter Roberson
Walter Roberson on 25 Jan 2016
Before the loop, use
bx = sym(zeros(15,1));
dx = sym(zeros(15,1));

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!