emptying each row of a matrix in a loop

1 visualizzazione (ultimi 30 giorni)
JL
JL il 22 Ago 2019
Commentato: JL il 22 Ago 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;
];

Risposta accettata

Matt J
Matt J il 22 Ago 2019
Modificato: Matt J il 22 Ago 2019
a0=a;
for i=1:size(a,1)
a=a0;
a(i,:)=[],
end
  4 Commenti
Matt J
Matt J il 22 Ago 2019
a0 is the original matrix. It is available throughout the loop.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Loops and Conditional Statements in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by