MATLAB: From 2D image, extract each complete row save as separate index in vector form

mextract row and save then

A 2D image of size 50×50, I wants to extract each complete row of image matrix and save it at separate index location if doing with for loop then how to save at each iteration of loop named with same loop variable. If it is possible with some other way please guide me. I don't have much knowledge in using matlab so please guide me Thanks

Best Answer

  • AsCell = mat2cell(YourImage, ones(1,size(YourImage,1)), size(YourImage,2));
    Now AsCell{K} stores the K'th row.
    But remember, when you know K you could just have invoked YourImage(K,:) without having to store the rows as separate variables.