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 Center および File ExchangeCharacters and Strings についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by