Assign values to a string in Matlab
2 次查看(过去 30 天)
显示 更早的评论
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]
0 个评论
回答(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
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!