Help with Symbolic For Loop
1 view (last 30 days)
Show older comments
So I have this code, and it works. But I can't figure out how to get it to store the answers of each of the 3 iterations. It only stores the last. I know it's something simple, maybe I've just been at it too long, but I can't seem to figure it out.
The Pnew = P(i) is in relation to P being 3 different load cases, i.e P = [0, 22.25, 44.5]
syms w(x) v(x)
Dw = diff(w);
Dv = diff(v);
for i = 1:1:3
Pnew = P(i)
% Delection in y direction
ode_v = diff(v,x,2) == -Izz/(E*den)*(Pnew*(L-x));
cond1_v = v(0) == 0;
cond2_v = Dv(0) == 0;
conds_v = [cond1_v cond2_v];
vSol(x) = dsolve(ode_v,conds_v);
vSol = vpa(simplify(vSol),3)
% Delection in Z direction
ode_w = diff(w,x,2) == Iyz/(E*den)*(Pnew*(L-x));
cond1_w = w(0) == 0;
cond2_w = Dw(0) == 0;
conds_w = [cond1_w cond2_w];
wSol(x) = dsolve(ode_w,conds_w);
wSol = vpa(simplify(wSol),3)
end
2 Comments
Answers (0)
See Also
Categories
Find more on Symbolic Math Toolbox 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!