Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Can someone explain me this part of array indexing?

I’m trying to manipulate an image with MATLAB, I want to flip the image without the function flip, so I found this, If someone knows how does it work can explain me?

img(:,(end:-1:1),:,:);

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Try it yourself, see the example below:

A = 1:10
A(end:-1:1)
A =

     1     2     3     4     5     6     7     8     9    10
ans =

    10     9     8     7     6     5     4     3     2    1   

end is the last element of the array, start:step:end creates an array starting at start, ending at end with step size step. Setting the step negative flips the array. This can be done across all dimensions of an array, so across the second in your case.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading