Creating a random matrix with specific values?
조회 수: 2 (최근 30일)
이전 댓글 표시
Hello,
Can someone guide me how to generate a random matrix in Matlab with only specific values in it.
For example, lets say I need a 1*100 element array with values only 0,90,180 in it. How can I do it using Matlab.
Many Thanks
댓글 수: 0
채택된 답변
Guillaume
2020년 2월 20일
valueset = [0, 90, 180];
desiredsize = [1, 100];
desiredmatrix = valueset(randi(numel(valueset), desiredsize))
댓글 수: 0
추가 답변 (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!