how would I create a 6x6 matrix with evenly distributed values from -10 to 10?
조회 수: 13 (최근 30일)
이전 댓글 표시
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
채택된 답변
Jon
2016년 2월 13일
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
추가 답변 (1개)
Walter Roberson
2016년 2월 13일
randi([-10,10],6,6)
If you want integer values.
rand(6,6)*20-10
if you want continuous values
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!