How to create a cell array of different data type?
이전 댓글 표시
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?
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Cell Arrays에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!