Splitting A String into variables

조회 수: 2 (최근 30일)
Elliot Alderson
Elliot Alderson 2019년 11월 30일
댓글: Elliot Alderson 2019년 12월 1일
I want to convert a string into an array that holds the individual characters of the string. for example, if I have:
a=input('enter calc: ','s');
And I enter 1+1
Is there a method to store the values as individual characters in an array, such as
char[1]='1';
char[2]='2';
char[3]='3';

채택된 답변

Steven Lord
Steven Lord 2019년 11월 30일
The code you posted already does this.
>> a=input('enter calc: ','s')
enter calc: 1+1
a =
'1+1'
>> a(1)
ans =
'1'
>> a(2)
ans =
'+'
  댓글 수: 1
Elliot Alderson
Elliot Alderson 2019년 12월 1일
Thank you for the clarification.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Characters and Strings에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by