how would I create a 6x6 matrix with evenly distributed values from -10 to 10?
9 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Jonathan Trencheny
am 13 Feb. 2016
Beantwortet: Walter Roberson
am 13 Feb. 2016
I know a long way, by typing out the exact values, I was just curious as to if there was a more efficient way.
0 Kommentare
Akzeptierte Antwort
Jon
am 13 Feb. 2016
Not entirely sure how you want the values distributed (by row or column), but see if this helps:
Msize = 6;
n = Msize^2;
values = linspace(-10,10,n);
matrix = reshape(values,Msize,Msize);
0 Kommentare
Weitere Antworten (1)
Walter Roberson
am 13 Feb. 2016
randi([-10,10],6,6)
If you want integer values.
rand(6,6)*20-10
if you want continuous values
0 Kommentare
Siehe auch
Kategorien
Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!