Cell to String Conversion
Show older comments
I have created a cell from another cell with a 1,n dimension.
I would like to convert the values in the 1,n cell to a matrix of strings for a following if statement.
Is there a simple function for this conversion similar to cell2mat?
If not, what is the easiest way of achieving this conversion?
I don't want to specify the values in the cell manually, but rather have the code transcribe it, this would cater for dynamic cell values.
Accepted Answer
More Answers (1)
Hi, conversion cell to string is automatic. Eg: given a following cell X:
{1,1} -> [1 2 3]
{1,2} -> [aa bb cc]
now extract the 2nd element of X:
s=X{2};
s is now a string cell 1x3
now you can do a "for" loop to get string value of each element of the last cell like that:
x=s{i};
Categories
Find more on Characters and Strings in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!