How to create a cell array of different data type?
Afficher commentaires plus anciens
I am trying to create a cell array of different data type to a single matrix
- Take the first eleven columns. Some columns have decimals and characters.
- Take all the rows of data and store them on one single matrix
I am proceding the following way,
clc,clear all
urlwrite('http://www.ndbc.noaa.gov/data/realtime2/41053.txt','SJ.txt'); % URL from CARICOOS
fid = fopen( 'SJ.txt', 'rt' );
DataCell = textscan(fid, '%d%d%d%d%d%d%f%f%s%s%s*[^\n]', 'HeaderLines', 2, 'CollectOutput', 1) ;
fclose(fid);
Data = cell2mat(DataCell);
MATLAB outputs this error,
??? Error using ==> cell2mat at 47
All contents of the input cell array must be of the same data type.
Error in ==> SJ_F at 11
Data = cell2mat(DataCell);
This is the way I want it stored
Data =
Columns 1 through 10
'2013' '02' '23' '23' '50' '110' '5.0' '7.0' 'MM' 'MM'
Column 11
'MM' % This is just one row of the data.
Could you please help?
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Cell Arrays dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!