1

I have a Matlab file that I'm looking to convert into Python. Part of it is functions and I'm a bit confused by it. In the Matlab code, there is a function that looks like this:

function [u, v, speed, dir] = NewCalculations(data)

Would the Python equivalent of this be?:

def NewCalculations(data):
    u = data.u
    v = data.v
    speed = data.speed
    dir = data.dir

I have read up on Matlab functions, but am still confused by the syntax and how it could be rewritten into Python. Any help/suggestions would be greatly appreciated!

1 Answer 1

1

It would be like this:

def NewCalculations(data):
# some calculations
    return u, v, speed, dir

The matlab syntax is

function outvars = functionname(inputvars)
Sign up to request clarification or add additional context in comments.

1 Comment

Ah, gotcha, ok. So anything on the left hand side of the equal sign in Matlab would be the returned variables then in a Python function, if I'm understanding correctly?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.