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
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);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With