Converting Matlab function to Python

Question:

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!

Asked By: matrix_season

||

Answers:

It would be like this:

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

The matlab syntax is

function outvars = functionname(inputvars)
Answered By: Mohammad
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.