How to create a cell array with wave data?
1 次查看(过去 30 天)
显示 更早的评论
Greetings,
I am trying to create a {... x 4} cell array with the following data.
#YY MM DD hh mm WVHT SwH SwP WWH WWP SwD WWD STEEPNESS APD MWD
#yr mo dy hr mn m m sec m sec - degT - sec degT
2012 12 17 16 54 1.1 0.4 10.5 0.9 9.1 N N AVERAGE 6.9 355
2012 12 17 16 24 1.1 0.4 10.5 1.0 9.9 N N AVERAGE 6.9 6
2012 12 17 15 54 1.0 0.5 10.5 0.9 9.1 N N AVERAGE 7.4 6
2012 12 17 15 24 1.1 0.4 11.1 0.9 9.9 NNE N AVERAGE 7.7 9
2012 12 17 14 54 1.1 0.4 10.5 0.9 9.9 N N AVERAGE 7.9 359
2012 12 17 14 24 0.9 0.5 10.5 0.8 9.1 N N AVERAGE 7.6 3
2012 12 17 13 54 0.9 0.4 10.5 0.8 9.9 N N AVERAGE 7.5 9
2012 12 17 13 24 1.0 0.5 10.5 0.8 9.9 N NNE AVERAGE 7.7 18
2012 12 17 12 54 1.0 0.5 10.5 0.8 9.9 N N AVERAGE 7.8 358
.
.
.
I want to take the first five columns (yr mo dy hr mn) and make it the first cell array. Then take all the rows starting from the third row, keeping in mind the program updates daily and the number of rows varies.
If you help me with this I can deal with the other 3 columns of the cell array
So far the code goes like this,
clc,clear all
fid = urlwrite('http://www.ndbc.noaa.gov/data/realtime2/41115.spec','Rincon.txt'); % URL from CARICOOS
Could you please help?
采纳的回答
per isakson
2012-12-17
This is a start:
function cac = cssm()
fid = fopen( 'cssm.txt' );
cac = textscan( fid, '%d%d%d%d%d%f%f%f%f%f%s%s%s%f%f' ...
, 'Delimiter' , ' ' ...
, 'CollectOutput' , true ...
, 'HeaderLines' , 2 ...
, 'MultipleDelimsAsOne' , true ...
, 'Whitespace' , '' ...
);
fclose( fid );
end
where cssm.txt is copy&pasted from your question. tab might be the delimiter in the file. Running cssm returns something.
>> c = cssm()
c =
[9x5 int32] [9x5 double] {9x3 cell} [9x2 double]
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Text Files 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!