Re: How to plot functions
- To: mathgroup at smc.vnet.net
- Subject: [mg130117] Re: How to plot functions
- From: Helen Read <readhpr at gmail.com>
- Date: Sun, 10 Mar 2013 17:07:52 -0400 (EDT)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
- Delivered-to: l-mathgroup@wolfram.com
- Delivered-to: mathgroup-newout@smc.vnet.net
- Delivered-to: mathgroup-newsend@smc.vnet.net
- References: <khh6p6$ako$1@smc.vnet.net>
You need an underscore to indicate that c is a variable. f[c_]:=c x^2 Plot[f[3],{x,-10,10}] It is also a good idea to make x a variable, like this. Clear[f] f[x_,c_]:=c x^2 Plot[f[x,3],{x,-10,10}] Manipulate[Plot[f[x, c], {x, -10, 10}, PlotRange -> 500], {c, -5, 5}] Or like this. Clear[f] f[c_][x_] := c x^2 Plot[f[3][x], {x, -10, 10}] Manipulate[Plot[f[c][x], {x, -10, 10}, PlotRange -> 500], {c, -5, 5}] I prefer this latter style of notation if I am thinking of one of the variables (here c) as a subscript or parameter, as opposed to defining a multivariate function that I would plot with Plot3D. Helen Read University of Vermont On 3/10/2013 12:47 AM, radres wrote: > Hi, > > Let's say I've defined a function f[c]=c*x^2 > > when I try to plot this directly, > > Plot[ f[3], {x, -10, 10} ] > > it doesn't plot anything. > > But when I assign function to a variable, > > v1=f[3]; Plot[v1, {x, -10, 10}] > > then there is no problem. But I dont want this. Is there any way to plot directly from a function? >