calling more than 2 matrix for for loop
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
sampath kumar punna
il 26 Ott 2019
Commentato: David Hill
il 26 Ott 2019
A =
8 9
15 39
23 14
18 2
13 17
40 18
14 39
38 42
x1= A([1,2,3,5,8],:)
x2= A([1,2,3,4,8],:)
x3=A([1,2,3,5,7],:)
x4=A([1,2,3,4,5,8],:)
can i have a for loop which can call x1, x2,x3,x4 in an order
2 Commenti
Risposta accettata
David Hill
il 26 Ott 2019
Why not make a cell array?
x{1}= A([1,2,3,5,8],:);
x{2}= A([1,2,3,4,8],:);
x{3}=A([1,2,3,5,7],:);
x{4}=A([1,2,3,4,5,8],:);
for i=1:4
y{i}=x{i}/2;
end
2 Commenti
David Hill
il 26 Ott 2019
Maybe I misunderstood you, it works for me and produces a cell array (y) having matrix elements that are the elements of x divided by 2.
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Matrix Indexing 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!