How can assign numbers between two integer numbers instead of ones in a [0 1] matrix?

조회 수: 2 (최근 30일)
Hi everyone,
I formed following matrice using randi([0,1],6,5).
1 0 1 0 0
1 0 1 0 0
1 0 0 0 1
0 1 0 0 1
1 1 1 0 1
1 1 0 1 0
In this matrice, I want to assign random numbers that between two integer nembers instead of just ones. This is possible? Thanks.

답변 (1개)

Matt J
Matt J 2023년 6월 11일
편집: Matt J 2023년 6월 11일
Sure.
randi([lower,upper], 6,5)
  댓글 수: 2
Abdullah Türk
Abdullah Türk 2023년 6월 11일
Matt thanks but I want assign random numbers to ones in the matrice. I firstly create [0 1] matrice and then in this matrice, I want to assign random numbers that between two integer numbers to ones.
Matt J
Matt J 2023년 6월 11일
lower=3;
upper=7;
randi([0,1], 6,5).*randi([lower,upper],6,5)
ans = 6×5
0 0 0 0 7 4 0 0 4 4 0 0 0 6 4 0 6 0 0 4 0 0 3 0 0 0 0 7 7 3

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

제품


릴리스

R2015a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by