Filter löschen
Filter löschen

Generate a sequence/vector of randomized letters

4 Ansichten (letzte 30 Tage)
Dan
Dan am 17 Aug. 2022
Kommentiert: Dan am 17 Aug. 2022
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)

Akzeptierte Antwort

KSSV
KSSV am 17 Aug. 2022
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 Kommentar
Dan
Dan am 17 Aug. 2022
Thank you, it was just what I was looking for! Appreciate it!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu MATLAB Report Generator finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by