2

This is a valid use of an anonumous function in MATLAB, where I define FootToHead() function in another file

f2h = @(x,xdata)FootToHeadY(x,xdata,rawPoints(1,6)/100.);

Is it possible to make the same thing using lambda functions in Python?

1 Answer 1

3

Yes you can easily do this with a lambda

f2h = lambda x, xdata: FootToHeadY(x, xdata, rawPoints(1,6) / 100.);

In a lambda function, the input arguments are in a comma-separated list between the lambda and the :. The contents of the lambda function are identical to the contents of your anonymous function.

To actually invoke this function, you'd need to call f2h with your desired inputs (just like you would in MATLAB)

f2h(1, 2)
Sign up to request clarification or add additional context in comments.

2 Comments

Doing so the interpreter doesn't even enter in the function FootToHeadY().
@fsart: Of course it doesn't. It wouldn't enter FootToHeadY in your Matlab code either. You didn't call f2h.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.