Basically, I'm looking for compilation flipudand fliplrtranslation of i-nd-array measurements.
When the dimension to be flipped is the first, I guess I can use
function flipped = flipfirst(ndarr)
sz = size(ndarr);
flipped = reshape(flipud(reshape(ndarr, sz(1), [])), sz);
end
Similarly, if the dimension to be flipped is the last, I could use
function flipped = fliplast(ndarr)
sz = size(ndarr);
flipped = reshape(fliplr(reshape(ndarr, [], sz(end))), sz);
end
I'm sure I can code something more general, with calls permuteand something else, but is there anything for this?
I'm not sure how expensive it is to do all the reshapeabove, but if so, I will also be interested in more efficient non-built approaches.
source
share