from cell array to numeric vector
Ältere Kommentare anzeigen
I have a 1x52 length cell array of years stored in MWDIData_years, i need to get these to be a nummeric vector. I am trying something like
x = cell2mat(MWDIData_years(:));
But it gives me a 52x4 matrix of chars where each adress in the matrix is a single number, ie 1994 becomes 1 9 9 4.
How can i get around this problem ?
Thank you
Thor
Akzeptierte Antwort
Weitere Antworten (1)
Mark Whirdy
am 16 Dez. 2012
yearCellArray = {'2008';'2009';'2010'};
yearVector = cellfun(@str2double,yearCellArray);
3 Kommentare
DoVile Last Name:
am 16 Dez. 2012
Andrei Bobrov
am 16 Dez. 2012
just
y = {'2008';'2009';'2010'};
str2double(y);
DoVile Last Name:
am 16 Dez. 2012
Kategorien
Mehr zu Data Type Conversion finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!