The Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.


Math Forum » Discussions » Inactive » comp.soft-sys.math.mathematica

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Array from for-loop iterations
Replies: 5   Last Post: Mar 3, 2011 6:04 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Bob Hanlon

Posts: 2,604
Registered: 1/29/05
Re: Array from for-loop iterations
Posted: Mar 3, 2011 6:04 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

vec = Array[a, {8, 3}];

f0 = 0.5;

sol1 = (#[[3]] - f0)^2 + (#[[1]] - f0) (#[[2]] - #[[1]]) -
(#[[2]] - f0) (#[[3]] - f0) & /@ vec

sol1 == Table[(vec[[k, 3]] - f0)^2 + (vec[[k, 1]] - f0) (vec[[k, 2]] -
vec[[k, 1]]) - (vec[[k, 2]] - f0) (vec[[k, 3]] - f0), {k,
Length[vec]}]

True


Bob Hanlon

---- Lengyel Tamas <lt648@hszk.bme.hu> wrote:

==========================
Dear Mathworld Community,

I am tackling a simple problem,

I have written a simple for-loop using elements from an array of
3-dimensional vectors:

f0=0.5;
For[k = 1, k < 9, k++,

(vec[[k, 3]] - f0)^2 + (vec[[k, 1]] - f0) (vec[[k, 2]] - vec[[k, 1]]) -
vec[[k, 2]] - f0) (vec[[k, 3]] - f0)
]

I don't know how to make an array out of the computed results.

Please help my silly soul.

Thank you.

Tam=C3=A1s





Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.