1 view (last 30 days)

Show older comments

I have a matrix, a

a = [1 2;

1 3;

1 5;

1 7;

1 8;];

and this matrix a, is emptied in each row per loop until the last one using this code from Matt J

a0=a;

for i=1:size(a,1)

a=a0;

a(i,:)=[],

end

which result in:

a = [1 3;

1 5;

1 7;

1 8;];

a = [1 2;

1 5;

1 7;

1 8;];

a = [1 2;

1 3;

1 7;

1 8;];

a = [1 2;

1 3;

1 5;

1 8;];

a = [1 2;

1 3;

1 5;

1 7;];

can I create another loop to calculate a certain value, w, from the results from each loop beginning with the orginal until the last one. After each loop answer value, w, is tabulated in matrix b

b = [w

w

w

w

w

w]

there 6 values of w since we consider the orginal a

David Hill
on 22 Aug 2019

How about,

preallowcating array b = zeros(size(a,1)-1,2,size(a,1));

and having the following in the loop

b(:,:,i)=a;

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!