For loop
Posted: Mon Oct 02, 2023 2:46 am
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
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