Copy one matrix into another in Matlab

18,086

just do:

  newImg = middleImg;

If what you meant is to copy everything but the first row and col, then just:

 newImg = middleImg(2:end,2:end);
Share:
18,086
JAN
Author by

JAN

The biggest C# and JAVA enthusiastic ever existed.

Updated on June 04, 2022

Comments

  • JAN
    JAN almost 2 years

    How can I copy one matrix into another without for loops ? is it even possible ?

    This is a short code that does it with loops , how can I avoid loops here ?

    % middleImg , newImg are matrices 
    [rows columns] = size(middleImg);
    for i=1:rows
        for j=1:columns     
            newImg(i,j) = middleImg(i+1,j+1);
        end
    end