If I want to plot this code for every n how should I try it? I want to plot M V and y. It doesn’t show anything right now. If I use n as example equal to 4, I want a plot with n=1 n=2 n=3 n=4 Any idea?
Remove["Global`*"]
n = 4;
y = Sum[x^i*a[i], {i, 2, n}];
th = D[y, x];
M = EI*D[y, {x, 2}];
V = EI*D[y, {x, 3}];
PE = EI/2*Integrate[D[y, {x, 2}]^2, {x, 0, L}] + P*(y /. x -> L);
Eq = Table[D[PE, a[i]], {i, 1, n}];
sol = Solve[Eq == 0, Array[a, n]]
y /. sol
th /. sol
Eq /. sol;
FullSimplify[M /. sol[[1]]]
FullSimplify[V /. sol[[1]]]
EI = 100;
P = 1;
L = 10;
Plot[{M, -100, 100}, {x, 0, L}, AxesLabel -> {"x (m)", "M (N.m.)"},
PlotLegends -> {Style[" M", Bold, 12]}]