MATLAB: How would I create a 6×6 matrix with evenly distributed values from -10 to 10

matrixmatrix manipulation

I know a long way, by typing out the exact values, I was just curious as to if there was a more efficient way.

Best Answer

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);