I have an array A
size of 16X16
and I want to add first 3 rows out of 16 in A
. What is the most efficient solution in MATLAB?
I tried this code but this is not efficient because I want to extend it for large arrays:
filename = 'n1.txt';
B = importdata(filename);
i = 1;
D = B(i,:)+ B(i+1,:)+ B(i+2,:);
For example, if I want to extend this for an array of size 256x256
and I want to extract 100 rows and add them, how I will do this?