How works for loop ?

How works for loop ? - for loop generates extra zeros - Messages

#1 Posted: 4/19/2019 10:09:59 AM
inazuma

inazuma

0 likes in 1 posts.

Group: User

Hello,

I'm a newbie in SMath, so maybe it's just a bad usage.

Why the following for loop:

I:=[5..10]
for i € I
xi := i

generate this result:
x=[0 0 0 0 5 6 7 8 9 10]

Thank you for your answer !
#2 Posted: 4/19/2019 10:51:58 AM
Martin_B

Martin_B

21 likes in 84 posts.

Group: User

You are assigning the values 5 to 10 to the 5th, 6th ...up to 10th element of the vector x.
The first 4 elements are filled with zeros.
1 users liked this post
Davide Carpi 4/20/2019 5:37:00 AM
#3 Posted: 4/19/2019 8:51:22 PM
Jean Giraud

Jean Giraud

983 likes in 6866 posts.

Group: User

Wrote

Why the following for loop:


Pad.PNG
1 users liked this post
Davide Carpi 4/20/2019 5:37:00 AM
  • New Posts New Posts
  • No New Posts No New Posts