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

For the for loop you could just use
syms y(x)
for i = 1:3
z(i) = y^i;
end
Terry Poole
Terry Poole 2021년 3월 31일
편집: Terry Poole 2021년 3월 31일
Yep, that did it, I just had to soak in what you were telling me. THANKS!!!

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

도움말 센터File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

제품

릴리스

R2019b

질문:

2021년 3월 31일

편집:

2021년 3월 31일

Community Treasure Hunt

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

Start Hunting!

Translated by