Assign values to a string in Matlab
古いコメントを表示
For example I have:
X ='abcaaabc';
How can I get it like
Y= [a b c a a a b c];
and
Y1= [0 1 2 0 0 0 1 2]
回答 (2 件)
Fangjun Jiang
2019 年 10 月 16 日
Y1=X-97
1 件のコメント
Fangjun Jiang
2019 年 10 月 16 日
編集済み: Fangjun Jiang
2019 年 10 月 16 日
You can't have the Y you want. Maybe Y=[X(:)], or Y=transpose(string(X'))
Stephen23
2019 年 10 月 16 日
>> X = 'abcaaabc';
>> Y = num2cell(X)
Y =
'a' 'b' 'c' 'a' 'a' 'a' 'b' 'c'
>> Y1 = X-97
Y1 =
0 1 2 0 0 0 1 2
カテゴリ
ヘルプ センター および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!