Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2008

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

Search the Archive

Re: Set::setps problems

  • To: mathgroup at smc.vnet.net
  • Subject: [mg90281] Re: [mg90251] Set::setps problems
  • From: DrMajorBob <drmajorbob at att.net>
  • Date: Fri, 4 Jul 2008 03:58:51 -0400 (EDT)
  • References: <15860788.1215088335161.JavaMail.root@m08>
  • Reply-to: drmajorbob at longhorns.com

Nonsense here without a definition for "step", but after supplying one, no  
problem:

step = Pi/10;
T = Table[{s, 0}, {s, -Pi, Pi, step}];
For[i = 1, i <= Length[UU], i += 1, UU[[i]][[2]] += 5];

The loop didn't do anything, of course, since

Length@UU

0

Perhaps you meant:

step=Pi/10;
T=Table[{s,0},{s,-Pi,Pi,step}];
For[i=1,i<=Length[T],i+=1,T[[i]][[2]]=T[[i]][[2]]+5];
Set::setps: T[[i]] in the part assignment is not a symbol. >>
Set::setps: T[[i]] in the part assignment is not a symbol. >>
Set::setps: T[[i]] in the part assignment is not a symbol. >>
General::stop: Further output of Set::setps will be suppressed during this  
calculation. >>

Looking at an example will show the problem:

T[[3]]

{-((4 \[Pi])/5), 0}

T[[3]][[2]]

0

As the error messages say, 0 is not a symbol, so of course you can't Set  
it or add 5 to it.

This works, however:

step = Pi/10;
T = Table[{s, 0}, {s, -Pi, Pi, step}];
For[i = 1, i <= Length@T, i += 1,
  T = ReplacePart[T, {i, 2} -> T[[i, 2]] + 5]]
T

{{-\[Pi], 5}, {-((9 \[Pi])/10), 5}, {-((4 \[Pi])/5),
   5}, {-((7 \[Pi])/10), 5}, {-((3 \[Pi])/5), 5}, {-(\[Pi]/2),
   5}, {-((2 \[Pi])/5), 5}, {-((3 \[Pi])/10), 5}, {-(\[Pi]/5),
   5}, {-(\[Pi]/10), 5}, {0, 5}, {\[Pi]/10, 5}, {\[Pi]/5, 5}, {(
   3 \[Pi])/10, 5}, {(2 \[Pi])/5, 5}, {\[Pi]/2, 5}, {(3 \[Pi])/5,
   5}, {(7 \[Pi])/10, 5}, {(4 \[Pi])/5, 5}, {(9 \[Pi])/10, 5}, {\[Pi],
   5}}

or this:

step = Pi/10;
T = Table[{s, 0}, {s, -Pi, Pi, step}];
T += Table[{0, 5}, {s, -Pi, Pi, step}]

{{-\[Pi], 5}, {-((9 \[Pi])/10), 5}, {-((4 \[Pi])/5),
   5}, {-((7 \[Pi])/10), 5}, {-((3 \[Pi])/5), 5}, {-(\[Pi]/2),
   5}, {-((2 \[Pi])/5), 5}, {-((3 \[Pi])/10), 5}, {-(\[Pi]/5),
   5}, {-(\[Pi]/10), 5}, {0, 5}, {\[Pi]/10, 5}, {\[Pi]/5, 5}, {(
   3 \[Pi])/10, 5}, {(2 \[Pi])/5, 5}, {\[Pi]/2, 5}, {(3 \[Pi])/5,
   5}, {(7 \[Pi])/10, 5}, {(4 \[Pi])/5, 5}, {(9 \[Pi])/10, 5}, {\[Pi],
   5}}

Bobby

On Thu, 03 Jul 2008 05:12:58 -0500, Kazimierz Å?akomy  
<kazik.lakomy at gmail.com> wrote:

> Hi all,
> I found troubles with such a loop:
>
> T = Table[{s, 0}, {s, -Pi, Pi, step}];
>
> For[i = 1, i <= Length[UU], i += 1,
>   UU[[i]][[2]] += 5];
>
> (it's just the example of some general idea of changing values of
> table's elements inside a loop)
>
> And Mathematica returned:
>
> Set::setps: UU[[i]] in the part assignment is not a symbol. >>
> Set::setps: UU[[i]] in the part assignment is not a symbol. >>
> Set::setps: UU[[i]] in the part assignment is not a symbol. >>
> General::stop: Further output of Set::setps will be suppressed during \
> this calculation. >>
>
> I would be very grateful if someone helped me with the issue.
> Thank you in advance.



-- 
DrMajorBob at longhorns.com


  • Prev by Date: Re: Set::setps problems
  • Next by Date: programming a simple neural network
  • Previous by thread: Re: Set::setps problems
  • Next by thread: Re: Happy Birthday Mathematica!