Assign values to a string in Matlab

조회 수: 2 (최근 30일)
Laura Paola Goyeneche Gomez
Laura Paola Goyeneche Gomez 2019년 10월 16일
답변: Stephen23 2019년 10월 16일
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
Fangjun Jiang 2019년 10월 16일
Y1=X-97
  댓글 수: 1
Fangjun Jiang
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
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

카테고리

Help CenterFile Exchange에서 Data Types에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by