emptying each row of a matrix in a loop

1 view (last 30 days)
JL
JL on 22 Aug 2019
Commented: JL on 22 Aug 2019
Is there a way to empty each row of a matrix in a loop? For example
a = [1 2;
1 3;
1 5;
1 7;
1 8;];
first loop
a = [
1 3;
1 5;
1 7;
1 8;];
second loop
a = [1 2;
1 5;
1 7;
1 8;];
and so on until the last loop
a = [1 2
1 3;
1 5;
1 7;
];

Accepted Answer

Matt J
Matt J on 22 Aug 2019
Edited: Matt J on 22 Aug 2019
a0=a;
for i=1:size(a,1)
a=a0;
a(i,:)=[],
end
  4 Comments
Matt J
Matt J on 22 Aug 2019
a0 is the original matrix. It is available throughout the loop.

Sign in to comment.

More Answers (0)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!