Generate a random matrix with 4 specifik values
조회 수: 6 (최근 30일)
이전 댓글 표시
hello i want to generate a random matrix tnat has 16 rows and 10^5 coloums that contains 4 differen values [-1,1,-j,j]. can anyone help me
댓글 수: 0
답변 (1개)
Jeff Miller
2020년 11월 24일
maybe this?
j = 2.5; % insert whatever value of j you want to use
vals = [1,-1, j, -j];
pos = randi(numel(vals),15,10^5);
randmatrix = vals(pos);
댓글 수: 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!