MathGroup Archive 2000

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

Search the Archive

More troubles coming from indexed variables

  • To: mathgroup at smc.vnet.net
  • Subject: [mg25000] More troubles coming from indexed variables
  • From: Barbara DaVinci <barbara_79_f at yahoo.it>
  • Date: Fri, 1 Sep 2000 01:09:33 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

Cari MathGrouppisti

Some time ago a post of mine just concerned indexed
variables.
(I had replies, kind an learned, from many persons -
Matthias Bode, David Keith, Steven M. Christensen,
Otto Linsuain and Hartmut Wolf. 
I thank them all.)

Now an even worse trouble is running.
I'm writing an educational notebook
on least-square fit and in a subsection I must show
how the well-known
formula is carried out.

This provides a symbolic data set :
datsimx = Table[x[k], {k, 1, 10}]
datsimy = datsimx /. x -> y

{x[1], x[2], x[3], x[4], x[5], x[6], x[7], x[8], x[9],
x[10]}
{y[1], y[2], y[3], y[4], y[5], y[6], y[7], y[8], y[9],
y[10]}

Now I must declare x[1] ... x[10] and y[1] ... y[10]
to be costants
(otherwise D[] and Dt[] ...) .

I tried two ways, both ineffective.


(I)
-----------------------------------------------------

SetAttributes[SetAttributes, Listable];
SetAttributes[datsimx, Constant];
SetAttributes[datsimy, Constant];

but I get

  Attributes[datsimx]
  {Constant}

  Attributes[datsimx[[1]]]
  Attributes::ssle: Symbol, string, or
HoldPattern[symbol]
  expected at position 1 in Attributes[datsimx[[1]]]

I suppose that is because

Head[datsimx[[1]]]
x


instead of

Head[datsimx[[1]]]
Symbol

Therefore I'm not surprised seeing 


SetAttributes[#, Constant] & @ datsimx

fails too.

(II)
-----------------------------------------------------

I definded this function 

f[x_] := ToExpression[
    StringJoin[
      "Symbol[", ToString[x], "]"
      ]
    ]
SetAttributes[f, Listable]

whose aim is make x[i] "Symbol headed" ("so doing,
maybe, SetAttributes stops shouting its warning
messages", I deceived myself)

But f[datsimx] make me howling with pain again:


Symbol::string: String expected at position 1 in
Symbol[x[1]].
Symbol::string: String expected at position 1 in
Symbol[x[2]].
Symbol::string: String expected at position 1 in
Symbol[x[3]].
General::stop: Further output of Symbol::string will
be suppressed during this calculation.

(This message is rather unclear to me)

-------------------------------------------
Please, is there a way to get out alive ?
-------------------------------------------


Affettuosi saluti
(The above is an Italian idiom meaning something like
"yours sincerely")

Barbara Da Vinci


______________________________________________________________________
Do You Yahoo!?
Il tuo indirizzo gratis e per sempre @yahoo.it su http://mail.yahoo.it


  • Prev by Date: Financial Modeling with Mathematica - 12 and 13
  • Next by Date: Re: Functional or rules-based equivalent for procedural program
  • Previous by thread: Financial Modeling with Mathematica - 12 and 13
  • Next by thread: Re: More troubles coming from indexed variables