Message Boards Message Boards

0
|
4879 Views
|
4 Replies
|
2 Total Likes
View groups...
Share
Share this post:

Why do I have to evaluate twice before Plot correctly plots??

Posted 5 years ago

If I change EI to a different value, I have to evaluate twice before I get the correct PLOT, what is wrong here??? First evaluation:

enter image description here

I do not change any values, I only re-evaluate the equations a second time and the Plot corrects itself to the right values... this happens every time I change the value of P

enter image description here

yx = \!\(TraditionalForm\`
\*FractionBox[\(P\), \(6\ EI\)]\ \((2 
\*SuperscriptBox[\(L\), \(3\)]\  - \ 3 
\*SuperscriptBox[\(L\), \(2\)]\  + \ 
\*SuperscriptBox[\(x\), \(3\)])\)\);
v = (P x^2)/(6 EI) (x - 3 L);
L = 6; EI = 1000; P = 100;
yxmax == ((-1 + L) L^2 P)/(2 EI)
vmax == -((L^3 P)/(3 EI))
Plot[{yx, v}, {x, 0, 6}]
POSTED BY: Raymond Low
4 Replies
Posted 5 years ago

Yes, thank you John I keep forgetting the difference between

= -- assigns a value

== -- equates two expressions

:= -- delays evaluation

your method worked, also if I had used ":=" delayed evaluation also worked -- once you reminded me, I remembered....

POSTED BY: Raymond Low

Because yx=expr means "evaluate expr and set the value of y to it". If expr contains evaluatable subexpressions, they will be evaluated. Here, you're setting P after evaluating the expression that contains it. If P already had a value when you evaluated it in setting yx, changing its value will have no effect on yx.

For parameters like this, I like to use rules to define parameter sets. Leave P, EI, and L as undefined symbols, and define a parameter set as:

ps1= {EI->6, L->1000, P->100};

Then, at the point where you're ready to make the substitution of parameters for symbols, write expressions like yx/.ps1.

POSTED BY: John Doty
Posted 5 years ago

No, yx remains exactly the same, I might have clipped the P when I copied the image, but both formulas remain the same, nothing was changed. I only pressed "Shift -- Enter" a second time...But if you wish, look at the formula for "v" it is the same, yet the dimension on the y axis changed from -500 to -5...

POSTED BY: Raymond Low
Posted 5 years ago

yx is different in the two images.

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

Group Abstract Group Abstract