Effacer les filtres
Effacer les filtres

add a row to a matrix each loop

8 vues (au cours des 30 derniers jours)
james sinos
james sinos le 12 Sep 2021
Réponse apportée : Matt J le 12 Sep 2021
lets say i have a matrix somthing liek that:
for each loop there is a search for solutions,
if a solution is found for a, iteration loop it will be added as new row in the matrix , othere wise it will pass to find another solution .
how we can proceed ?
thanks

Réponses (1)

Matt J
Matt J le 12 Sep 2021
Just concatenate:
A=eye(5)
A = 5×5
1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1
newrow=rand(1,5);
A=[A;newrow]
A = 6×5
1.0000 0 0 0 0 0 1.0000 0 0 0 0 0 1.0000 0 0 0 0 0 1.0000 0 0 0 0 0 1.0000 0.5232 0.3248 0.2297 0.4854 0.3321

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Produits


Version

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by