How to enter extensive data to cell array?
4 次查看(过去 30 天)
显示 更早的评论
I am trying to store some extensive data to a cell array with specification:
- {1x1}, {1}[... x 5]
- Take the first five columns
- Ignore the first two lines and take all the rows following
- Ignore the white spaces character ('') between columns
- Store the data on the variable "Time"
The data should appear on the Workspace like this,
Time =
2013 2 23 21 30
%This is just one row of the data
The data is in this link,
So far I have proceed the following way,
function Data = SJ
fid = fopen( 'SJ.txt' );
Data = textscan( fid, '%d%d%d%d%d' ...
, 'Delimiter' , ' ' ...
, 'HeaderLines' , 2 ...
);
fclose( fid );
end
Could you please help?
0 个评论
采纳的回答
Walter Roberson
2013-2-23
fid = fopen( 'SJ.txt', 'rt' );
DataCell = textscan(fid, '%d%d%d%d%d%*[^\n]', 'HeaderLines', 2, 'Collect', 1) ;
fclose(fid);
Time = cell2mat(DataCell);
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Workspace Variables and MAT Files 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!