Help indexing symbolic ODE in for loop
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Terry Poole
el 31 de Mzo. de 2021
Comentada: Terry Poole
el 31 de Mzo. de 2021
Ok so my code works,
P = [0; 22.25; 44.5];
syms w(x) v(x)
Dw = diff(w);
Dv = diff(v);
for i = 1:3
% Deflection in y direction
ode_v = diff(v,x,2) == -Izz/(E*den)*(P(i)*(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)
% Deflection in Z direction
ode_w = diff(w,x,2) == Iyz/(E*den)*(P(i)*(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
And my output is:
vSol(x) =
0.0
wSol(x) =
0.0
vSol(x) =
1.41e+13*x^2*(x - 3.0)
wSol(x) =
3.14e+13*x^2*(x - 3.0)
vSol(x) =
2.82e+13*x^2*(x - 3.0)
wSol(x) =
6.29e+13*x^2*(x - 3.0)
>>
Which is correct for all 3 load cases,
My issue is, I'm not sure how to call each case, I can't say vSol(1), because it'll assume x=1 and solve the differential equation. So how would I "index" for lack of a better word each case to generate a plot of (v,w) vs. P? I assume since its a syms function that it's not storing these values as an array, honestly it doesn't seem like it's storing them at all.
Any help on how to call vSol(x)(1), vSol(x)(2) and so on would be greatly appreciated.
0 comentarios
Respuesta aceptada
Más respuestas (0)
Ver también
Categorías
Más información sobre Conversion Between Symbolic and Numeric en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!