Python Forum
Create a function vector
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Create a function vector
#1
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

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) 
Reply


Messages In This Thread
Create a function vector - by Cooketaker - Dec-27-2022, 01:42 AM
RE: Create a function vector - by deanhystad - Dec-27-2022, 03:59 AM
RE: Create a function vector - by Gribouillis - Dec-27-2022, 06:37 AM
RE: Create a function vector - by deanhystad - Dec-27-2022, 04:32 PM
RE: Create a function vector - by Cooketaker - Dec-27-2022, 08:22 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  substring function to create new column Chandan 6 2,611 Feb-14-2020, 10:11 AM
Last Post: scidam
  matrix by vector mcgrim 8 4,004 May-02-2019, 10:39 AM
Last Post: ichabod801
  How to create a random library for an specific function andre_fermart 4 3,427 Apr-10-2019, 11:02 PM
Last Post: andre_fermart
  Vector field cross product Eduard 2 2,643 Aug-20-2018, 02:54 PM
Last Post: Eduard

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020