Dealing with Character arrays

3 Ansichten (letzte 30 Tage)
Giorgos
Giorgos am 10 Jan. 2013
Hello everyone!
I have 3 (Date, Time, Pred) one-column character arrays and i want to create a new array with 3 columns. 1st column ---> Date, 2nd column ---> Time and 3rd Column ---> Pred. but i can't figure how to do that. Can anyone help me?
Thanks in advance,
Giorgos

Akzeptierte Antwort

José-Luis
José-Luis am 10 Jan. 2013
You probably need a cell array, especially if all the strings are not guaranteed to be of the same size.
col1 = char(reshape(32:127, 32, 3)'); %Some character array
col2 = col1;
col3 = col2;
%What you could use
your_cell_array = [cellstr(col1),cellstr(col2),cellstr(col3)];

Weitere Antworten (2)

Jan
Jan am 10 Jan. 2013
Bearbeitet: Jan am 10 Jan. 2013
So you have this, to mention it explicitly:
a = ['1'; '2'; '3'];
b = ['A'; 'C'; 'X'];
c = ['Q', '_', 'v'];
And these values represent Date, Time and Pred? Don't you think, that this is a very short representation? My guess is, that you do not have three [nx1] CHAR vectors. Anyhow, the solution would be:
R = [a,b,c]
Or equivalent:
R = cat(2, a, b, c);
If this is helpful, I strongly recommend to read the Getting Started chapters of the documentation, where such fundamental basics are explained.

Giorgos
Giorgos am 13 Jan. 2013
Bearbeitet: Giorgos am 13 Jan. 2013
Thanks for your time guys. José's answer was what i was looking for.

Kategorien

Mehr zu Time Series Objects finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by