What is the meaning of following code?

1 view (last 30 days)
Hi I would lioke to know the meaning of the following code
NewRes(:,:,Channel,:) = Residuals([1:2:size(Residuals,1)],[1:2:size(Residuals,1)],Channel,:);
what is the syntax here is suggesting. I would like to repesent this in Python.
Thanks

Accepted Answer

Walter Roberson
Walter Roberson on 18 Jun 2019
size(Residuals,1) is the number of rows in the Residuals array. 1:2:size(Residuals,1) is the odd-numbered rows. [1:2:size(Residuals,1)] in context is redundant and could be just 1:2:size(Residuals,1) .
So the odd-number rows are selected from Residuals, and the same numbering is used for the columns as well . That is a little risky unless Residuals is known to be the same number of rows and columns.
Channel is kept constant, a scalar, and used to index the third dimension.
All of the 4th dimension is selected.
So Newres in the third pane selected by Channel becomes the odd-numbered rows and columns of Residuals from the third pane selected by Channel.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!