matlab2python icon indicating copy to clipboard operation
matlab2python copied to clipboard

wrong handling of array indexing

Open SaschaRienaecker opened this issue 2 years ago • 1 comments

First of all, thank you for this nice project. When I try to convert the following lines,

  x = zeros(4,4)
  y = x(1,:)

I get a python output which is obviously wrong

import numpy as np
x = np.zeros((4,4))
y = x(1,:)

since x is an array and should be indexed using [ ] brackets and python indexing starting from 0. Is there an easy way to fix? This would be very helpful.

SaschaRienaecker avatar Mar 03 '23 18:03 SaschaRienaecker

Hi @SaschaRienaecker Unfortunately this is one of the greatest limitation.. There might be a way to somehow figuring out, based on context, which object is a variables and which is a function. If you are well versed in python, you can try diving into the code and come up with a suggestion? Even if it only works for the case with a "zeros" or "ones" initialization, it would still be useful. Thanks a lot!

The issue is the same as #4

ebranlard avatar Mar 03 '23 19:03 ebranlard