Reputation: 249
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.
Upvotes: 1
Views: 128
Reputation: 29093
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
Upvotes: 3
Reputation: 362597
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.
Upvotes: 1