Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2009

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: SetDelayed::write ... [x_] is protected

  • To: mathgroup at smc.vnet.net
  • Subject: [mg97920] Re: [mg97863] SetDelayed::write ... [x_] is protected
  • From: Richard Hofler <rhofler at bus.ucf.edu>
  • Date: Wed, 25 Mar 2009 05:47:06 -0500 (EST)
  • References: <200903241030.FAA19754@smc.vnet.net>

Jakub,

You'll probably get several better solutions than this one. However,. . .

In[25]:= sol={{i1->220/x},{i2->100+x}};
(* [[..]] is the Part function *)
myfun[x_]:=50*sol[[1,2]]+2*sol[[2,2]]

(* If want to see what Flatten does, evaluate this line without the ";" *)
sol = Flatten@sol <mailto:Flatten@sol> ;
myfun[x]

Out[28]= 11000/x + 2(100+x)

Richard Hofler

________________________________

From: Serych Jakub [mailto:Serych at panska.cz]
Sent: Tue 3/24/2009 6:30 AM
To: mathgroup at smc.vnet.net
Subject: [mg97920] [mg97863] SetDelayed::write ... [x_] is protected



Dear M users,
I have solution of equations which is dependend on one parameter lets say:
sol={{i1->220/x}, {i2 -> 100+x}} and I need to define function based on this
solution with the x as argument lets say: myfun[x_]:=50*220/x + 2 (100+x);

I'm trying to do it like this:

myfun[x_]:=50 * i1 + 2 * i2 /. sol

But it prints the error message: "SetDelayed::write ... [x_] is protected".

Does anybody know what's the problem and how to define such function?

Thanks in advance

Jakub



  • Prev by Date: Re: Incompatible units?
  • Next by Date: Re: SetDelayed::write ... [x_] is protected
  • Previous by thread: SetDelayed::write ... [x_] is protected
  • Next by thread: Re: SetDelayed::write ... [x_] is protected