필터 지우기
필터 지우기

How to create a cell array with wave data?

조회 수: 2 (최근 30일)
Juan Rosado
Juan Rosado 2012년 12월 17일
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?
  댓글 수: 2
Juan Rosado
Juan Rosado 2012년 12월 17일
Forgot to mention. The date is one big {1x1} array.
per isakson
per isakson 2012년 12월 17일
It can be done with textscan

댓글을 달려면 로그인하십시오.

채택된 답변

per isakson
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개)

카테고리

Help CenterFile Exchange에서 Large Files and Big Data에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by