필터 지우기
필터 지우기

Generate a sequence/vector of randomized letters

조회 수: 4 (최근 30일)
Dan
Dan 2022년 8월 17일
댓글: Dan 2022년 8월 17일
I would like to create a 1x10 row vector of randomized letters.
My code so far is:
a='A':'Z';
letters= a(randi(numel(a), 1, 10))
letters = 'FLNRJUMDZB'
I was wondering if I could have this sequence output in a way where each letter is spaced with a comma in between. Ex: Instead of 'ABCDE', I would like'A, B, C, D, E'. Thank you to whoever can help! (Note: I am quite new to MATLAB)

채택된 답변

KSSV
KSSV 2022년 8월 17일
a='A':'Z';
letters= a(randi(numel(a), 1, 10))
letters = 'XMYNVGHUIL'
iwant = strjoin(cellstr(letters'),',')
iwant = 'X,M,Y,N,V,G,H,U,I,L'
  댓글 수: 1
Dan
Dan 2022년 8월 17일
Thank you, it was just what I was looking for! Appreciate it!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 MATLAB Report Generator에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by