Hi
I would like to compute a variable in a For loop at scriptcontroller. I have done the following code in a script controller by lua
function init( model,par,side)
alpha0 = 1
alpha = 1
phi = 0
for i = 1,10 do
beta = alpha*sin(phi)
alpha_dot = beta + 2 -- differentiate alpha
alpha = math.modf (alpha) -- Integral alpha
end
end
In above code, I am attempting to compute alpha inside a FOR loop. But an error is occurred :
attempt to call a number value (global 'alpha')
How can I fix it?
Thanks in advance
For loop
- Thomas Geijtenbeek
- Posts: 432
- Joined: Wed Mar 12, 2014 8:08 am
Re: For loop
Perhaps add "math." before sin?
- Samane Amini
- Posts: 100
- Joined: Sun Jan 12, 2020 3:48 am
Re: For loop
Hi
I corrected it. But it still doesn't work. Actually, the alpha(i) which i=1 isn't recognized.
Best
I corrected it. But it still doesn't work. Actually, the alpha(i) which i=1 isn't recognized.
Best
- Thomas Geijtenbeek
- Posts: 432
- Joined: Wed Mar 12, 2014 8:08 am
Re: For loop
It appears "alpha" is a number and not a function, so you can't do alpha(i).