MATLAB Answers

emptying each row of a matrix in a loop

2 views (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

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by