how would I create a 6x6 matrix with evenly distributed values from -10 to 10?
52 views (last 30 days)
Show older comments
Jonathan Trencheny on 13 Feb 2016
Answered: Walter Roberson on 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.
Jon on 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);
More Answers (1)
Walter Roberson on 13 Feb 2016
If you want integer values.
if you want continuous values
Find more on Creating and Concatenating Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!