Message Boards Message Boards

0
|
5274 Views
|
1 Reply
|
1 Total Likes
View groups...
Share
Share this post:

How to use Manipulate&Plot with setting variables..?

Posted 11 years ago
Hello there,

it's my first time using mathematica and I need some help.
I want to plot a function f(x) which contains three variables x, k and t. I have to plot this function once for setting k=0 and t in [-2, 2], once for setting k=1 and t in [-3,3]

How can I do this? I tried

Manipulate[
                              Simplify[
                                               Plot[ f(x), {x, -5, 5}],
                               k = 0],
  {t, -2, 2}]

Mathematica shows error. What's the better way?
POSTED BY: K L
The problem may be just the syntax. I show below two ways to generate the desired plots.
 (* Clear memory *)
 Clear["Global`*"];
 
 (* To generate and grid two static plots. *)
 f[x_, k_, t_] := k x + t;
 (* A static plot calls for a contourplot so we can vary x and t at the same time. *)
 plot[k_, tlim_] := ContourPlot[ f[x, k, t],{t,-tlim,tlim},{x,-5,5}, ContourShading -> None ]
 (* Call each user defined (lowercase)plot function with a specific k and limiting t(tlim) *)
 Grid[{ {plot[0, 2], plot[1, 3]} }]

(* Using Manipulate. This time "t" is fixed (for convenience) to the larger range for all "k". *)
Manipulate[ Plot[ f[x,k,t], {x,-5,5},
PlotRange -> {Automatic, {-4,4}}](* Choose the range from observation. *)
{k,0,1,1,RadioButton}(* Specify k with a radio button *),
{t,-3,3,Slider}(* Specifiy t with a slider *)]
POSTED BY: Isaac Abraham
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