Group Abstract Group Abstract

Message Boards Message Boards

0
|
2.9K Views
|
6 Replies
|
2 Total Likes
View groups...
Share
Share this post:

Plot for every n to compare the result

Posted 5 years ago

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]}]
POSTED BY: Ali Sharahi
6 Replies
Posted 5 years ago

Plot for every n to compare the result

POSTED BY: Ali Sharahi

Just to differentiate the results for different n. For the n 's I tested the curves of the original problem are the same, so I added "something" to make them different - as a test. Completely arbitrary! You might as well add any other function of n to see that differerent n's give different results. When you then eliminate that additional term I think you will see only one line, indicating that you n has a neglibible influence on your result.

POSTED BY: Hans Dolhaine
Posted 5 years ago

It seems really good, but what I don't understand is, this part of your code.

Plot[{ n/2 +M /. sol, -100, 100}

why n/2+M/.sol?

POSTED BY: Ali Sharahi

Perhaps you meant something like this

pp[nn_] := Module[{},
  n = nn;
  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]];
  FullSimplify[M /. sol[[1]]];
  FullSimplify[V /. sol[[1]]];
  EI = 100;
  P = 1;
  L = 10;
  Plot[{M /. sol, -100, 100}, {x, 0, L}, 
   AxesLabel -> {"x (m)", "M (N.m.)"}]
  ]

Off[Solve::"svars"]
Show[Table[pp[j], {j, 3, 6}], PlotRange -> {-15, 15}]

It seems that all lines coincide.

If you change (just as a test)

Plot[{M /. sol, -100, 100}, {x, 0, L}, AxesLabel -> {"x (m)", "M (N.m.)"}]

to

Plot[{ n/2 +M /. sol, -100, 100}, {x, 0, L}, AxesLabel -> {"x (m)", "M (N.m.)"}]

you will see differences

POSTED BY: Hans Dolhaine

Welcome to Wolfram Community! Please make sure you know the rules: https://wolfr.am/READ-1ST Please next time link your post to the duplicated one from MSE site.

POSTED BY: EDITORIAL BOARD
Posted 5 years ago

Crossposted here.

POSTED BY: Rohit Namjoshi
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard