How do I simplify these commands to a single line in MATLAB?
medoidContainer(:, i, 1) = squeeze(reshape(container(:, :, 1),1, y * x));
medoidContainer(:, i ,2) = squeeze(reshape(container(:, :, 2),1, y * x));
medoidContainer(:, i ,3) = squeeze(reshape(container(:, :, 3),1, y * x));
With them, I reshape an RGB image to a matrix of a single line (for each color). But how can I do this without having to iterate through each dimension?
I have tried:
medoidContainer(:, i ,1:3) = squeeze(reshape(container(:, :, 1:3),1, y * x));
But that doesn’t work.
It sounds like you’re trying to convert an
M x N x 3array into an(M*N) x 3array. You can do this as follows:To assign it into your “container”, I think you need this: