Dec-27-2022, 01:42 AM
I want to create a function that is modified with a loop and then I can call those different functions from a function vector.
The function to be modified would be the Am function.
The problem is that it only uses the last value of the loop, i=1.
So I have two equal functions, with i=1.
What I want is to have an Am function with i=0, and another with i=1.
Then you can call them from the vector Afunctions
The function to be modified would be the Am function.
The problem is that it only uses the last value of the loop, i=1.
So I have two equal functions, with i=1.
What I want is to have an Am function with i=0, and another with i=1.
Then you can call them from the vector Afunctions
1 2 3 4 5 6 7 8 9 10 11 12 |
Afunctions = [] def Am(x): if ((x>xn[i]) and (x< = xn[i + 1 ])): return (x - xn[i]) / h1 elif ((x>xn[i + 1 ]) and (x<xn[i + 2 ])): return ( 1 - (x - xn[i + 1 ]) / h1) else : return 0 for i in range ( 0 , 2 , 1 ): Afunctions.append(Am) |