필터 지우기
필터 지우기

Random integer numbers using random function

조회 수: 1 (최근 30일)
KnowledgeSeeker
KnowledgeSeeker 2014년 2월 10일
댓글: KnowledgeSeeker 2014년 2월 10일
Hi, I am trying to obtain 9 random integer numbers and want them to be appeared in this form
expectedoutpt = '989898989' '897676767'
any suggestion?

채택된 답변

Mischa Kim
Mischa Kim 2014년 2월 10일
Something like:
function ri = rnum()
ri = num2str(randi([1,9],1,9));
ri = ri(~isspace(ri));
end

추가 답변 (1개)

Jos (10584)
Jos (10584) 2014년 2월 10일
Two strings of 9 random digits between 1 and 9 each (no 0?), stored in a row cell(?) array?
S = cellstr(char('0' + ceil(9*rand(2,9)))).'

카테고리

Help CenterFile Exchange에서 Random Number Generation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by