Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Convert cell array to string

Asked by Willam Willam on 25 Feb 2013

Hi. I want to ask how do I want to convert below example to a string which contains data in char. Eg: retrieveblock =

      0    1    1    1    0    0    0    1    0    1    1    0    0    0    0    1

1 Comment

Jan Simon on 1 Mar 2013

@William: Please post the input data such that we can know the class and the size. Currently it is not clear, if your data are a double vector, a cell vector or any equivalent data also. But guessing this detail wastes time.

Please use meaningful tags, because they are used to classify the questions. All questions in this forum concern "matlab".

Willam Willam

Tags

No tags are associated with this question.

Products

2 Answers

Answer by Sean de Wolski on 25 Feb 2013
x = rand(1,10)>0.5;
num2str(x)

If x was a cell array of strings you could always call char()

x = cellstr(num2str(rand(1,10)>0.5));
char(ans)

2 Comments

Willam Willam on 1 Mar 2013

excuse me.. it does not work

Jan Simon on 1 Mar 2013

Sean has offered two possible solutions. Answering "it does not work" does not allow to improve them. Please, William, post enough details.

Sean de Wolski
Answer by Jan Simon on 1 Mar 2013

Guessed input:

d = [0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1];
str = char(d + '0');

0 Comments

Jan Simon

Contact us