Index Matrix Rows and Columns on MATLAB, is this code ok?

Viewed 70

I have some code on MATLAB, which I have to translate it to Python to work with it. Going through the code I found this line:

filtered_proj (new_len, :, 1) = 0;

So after reading here MATLAB Documentation, I understood and tried to apply on my Python code. I created a matrix in Python using NumPy to test:

array([[1, 2],
       [3, 4],
       [5, 6]])

but when I try to access like it is written on MATLAB, with the following python code

a[1,:,1]

I get this message:

Traceback (most recent call last):
  File "<input>", line 1, in <module>
IndexError: too many indices for array

If I access like a[1: ,1] I get this:

array([4, 6])

And like a[1,: 1] I get this:

array([3])

So, is this MATLAB code really correct? If it is, how should I do that?

3 Answers
Related