Reputation: 539
I created an array of strings and I want to get the value of a given string at a given position, but the returned value is the character and not the string, eg:
myArray = ['string1' 'string2' 'string3'];
s = myArray(1); //returns the character at the position 1, instead of the string
How can I get the value of these strings based on a given position i ?
Upvotes: 0
Views: 31
Reputation: 861
Try using a cell array:
myArray = {'string1' 'string2' 'string3'};
s = myArray{1};
Upvotes: 1
Reputation: 23
You can do a for loop if this is what you are asking for.
myArray=['b' 'c' 'd']
for i =1:lenght(myArray)
s(i)=myArray(i);
end
Not sure what you are asking for exactly.
Upvotes: 0