Splitting A String into variables

3 vues (au cours des 30 derniers jours)
Elliot Alderson
Elliot Alderson le 30 Nov 2019
Commenté : Elliot Alderson le 1 Déc 2019
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';

Réponse acceptée

Steven Lord
Steven Lord le 30 Nov 2019
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 commentaire
Elliot Alderson
Elliot Alderson le 1 Déc 2019
Thank you for the clarification.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Data Type Conversion dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by