Create a square matrix with a nested loop
Mostra commenti meno recenti
-20 -18 -16 -14
-12 -10 -8 -6
-4 -2 0 2
4 6 10 12
can you create it with a loop inside
3 Commenti
madhan ravi
il 31 Ago 2020
Huh, expecting others to write your homework? Did you try anything at all?
Mehmet ali Karatas
il 31 Ago 2020
madhan ravi
il 31 Ago 2020
Post what you have tried, even if it has mistakes.
Risposte (2)
A = zeros(4) ;
A(1,:) = -20:2:-14 ;
A(2,:) = -12:2:-6 ;
A(3,:) = -4:2:2 ;
A(4,:) = 4:2:10 ;
1 Commento
Mehmet ali Karatas
il 31 Ago 2020
Clement Val
il 31 Ago 2020
Modificato: Clement Val
il 31 Ago 2020
reshape([-20:2:10], 4, 4)'
Just (half) kidding.
You know how to do a loop?
You know how to index in a 2 dim array?
You know how to increment another variable by two?
Categorie
Scopri di più su Loops and Conditional Statements in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!