Sample letters from a character array?

2 ビュー (過去 30 日間)
Jan Göttmann
Jan Göttmann 2018 年 7 月 9 日
コメント済み: Jan Göttmann 2018 年 7 月 9 日
Hey there!
I want to sample and save random letters to an array. It works fine, except the fact, that the saved data is numeric intead of characters. How can I recode the sampled data to character? Here my code so far.
expinfo.letters= ['B' 'C' 'D' 'F' 'G' 'H' 'J' 'K' 'L' 'M' 'N' 'P' 'Q' 'R' 'S' 'T' 'V' 'W' 'X' 'Z'];
[TrialConfig(:,4)] = randsample(expinfo.letters,720,true)
It works fine, but my output is:
TrialConfig =
5 2 0 72
5 0 1 80
5 1 0 68
5 1 1 82
5 2 1 87
5 2 1 80
5 1 0 87
5 2 0 88
5 1 1 83
5 1 1 81
Where the last column should be the sampled letters. Any suggestions? If I don't assign the sampled letters to an array, all is fine.
Thanks for your help so far!
*j

採用された回答

Walter Roberson
Walter Roberson 2018 年 7 月 9 日
Those are the numeric representations of the letters.
It is not possible to have a single array that has a mix of numbers and letters, not unless the array is either a cell array or a table (or timetable.)
  1 件のコメント
Jan Göttmann
Jan Göttmann 2018 年 7 月 9 日
Thanks! I now use a cell array for the data and it works fine !

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by