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!