Message Boards Message Boards

0
|
5037 Views
|
5 Replies
|
3 Total Likes
View groups...
Share
Share this post:

How Do I set a variable bigger than another variable?

Hello there,

This is my first experience with mathematica and I would like to give my plot the
"perfect" touch with telling my plot that it isnt allowed to pick any "r" bigger
than "a" so that r < a is true.

This is the code i entered:

r = 1; w = 2 \[Pi]; a = 2; v = 0.1;
Manipulate[
 ParametricPlot[{v*t (1 + 1/(1 - r/a*Cos[w*t])), (r*Sin[w*t])/(
   1 - r/a*Cos[w*t])}, {t, 0, 10}, 
  PlotRange -> {{-.5, 200}, {-100, 100}}], {r, 0.000000001, 100, 
  Appearance -> "Labeled"}, {a, 0.000000001, 100, 
  Appearance -> "Labeled"}, {v, 0.000000001, 20, 
  Appearance -> "Labeled"}, {w, 0.000000001, 20, 
  Appearance -> "Labeled"}]

This is the Output: I can make r<a but I want it to be a rule.

I would really appreciate it if someone got an answer to this :)

Best regards, Stephan

POSTED BY: Stephan Jokiel
5 Replies

Double post my bad.

POSTED BY: Stephan Jokiel

Wolfram posted the code automatically in the here but thanks I I'll definitely give it a try :) if it works how I think it works it might even be better than the "If []"

POSTED BY: Stephan Jokiel

Hi Stephan,

you simply can let 'r' run from 0.00.. to 'a':

Manipulate[
 ParametricPlot[{v*
    t (1 + 1/(1 - r/a*Cos[w*t])), (r*Sin[w*t])/(1 - 
      r/a*Cos[w*t])}, {t, 0, 10}, 
  PlotRange -> {{-.5, 200}, {-100, 100}}], {{r, 1}, 0.000000001, a, 
  Appearance -> "Labeled"}, {{a, 2}, 0.000000001, 100, 
  Appearance -> "Labeled"}, {{v, 0.1}, 0.000000001, 20, 
  Appearance -> "Labeled"}, {{w, 2 Pi}, 0.000000001, 20, 
  Appearance -> "Labeled"}]

Also please note the way of initialization of the parameters which was probably inteded by you originally.

Yours Henrik

POSTED BY: Henrik Schachner

Wow, this is genius, thanks alot ;D enter image description here

POSTED BY: Stephan Jokiel

Hi,

You can use If[]:

Manipulate[
    If[
       r < a,
       ParametricPlot[
         {v*t (1 + 1/(1 - r/a*Cos[w*t])), (r*Sin[w*t])/(1 - r/a*Cos[w*t])},
         {t, 0, 10}, 
         PlotRange -> {{-.5, 200}, {-100, 100}}
       ],
       Graphics[Text["error :: r > a"]]
    ], 
    {r, 0.000000001, 100, Appearance -> "Labeled"},
    {a, 0.000000001, 100, Appearance -> "Labeled"},
    {v, 0.000000001, 20,  Appearance -> "Labeled"},
    {w, 0.000000001, 20,  Appearance -> "Labeled"}
]

I.M.

POSTED BY: Ivan Morozov
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