string problem

4 次查看(过去 30 天)
Edward
Edward 2012-5-11
hi, i have two strings
string1='a'
string2='b'
how do i get these into an array so i get:
total=['a', 'b']
I know the above is easy, but i want to be able to add n strings together into the total string array, n has to be defined by the user, in this case it is 2. (the strings can be anything i have just used the alphabet as an example)
I hope this makes sense!
  2 个评论
Walter Roberson
Walter Roberson 2012-5-11
http://www.mathworks.com/matlabcentral/answers/29922-why-your-question-is-not-urgent-or-an-emergency
Walter Roberson
Walter Roberson 2012-5-11
Duplicate is at http://www.mathworks.com/matlabcentral/answers/38113-plot-help

请先登录,再进行评论。

回答(1 个)

the cyclist
the cyclist 2012-5-11
Can you just use cell arrays?
total = {'a','b'}
Here's an overview:
  2 个评论
Edward
Edward 2012-5-11
i could but that wouldn't allow me to add a different amount of strings into the array each time.
The amount of strings i need in the array is defined by the user.
Im hoping to use it to label a plot legend with n variables.
Walter Roberson
Walter Roberson 2012-5-11
See your other question that this one duplicates.

请先登录,再进行评论。

类别

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