1

I have a matlab function

function [indx, indy] = coord2index(hres, vres, hdiv, vdiv, x, y)

  indx = hdiv + x + 1;

  indy = -1*y + vdiv;

How can I convert it to python function.

2 Answers 2

3

I can be wrong but have you tried this:

def coord2index(hres, vres, hdiv, vdiv, x, y):
    return hdiv + x + 1, (-1) * y + vdiv

You can read more on functions defining in python tutorial

Sign up to request clarification or add additional context in comments.

Comments

1

I guess it would be something like this:

def coord2index(hres, vres, hdiv, vdiv, x, y):
  indx = hdiv + x + 1
  indy = -1*y + vdiv
  return indx, indy

Assuming your inputs are numpy.ndarray the shape broadcasting should work the same as matlab.

Comments

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.