フィルターのクリア

How do I input this information in a cell array

1 回表示 (過去 30 日間)
Juan Rosado
Juan Rosado 2013 年 2 月 17 日
I have this text file and I want to store the fist 4 columns, starting from the third row in a variable called 'Time'
The text file is this,
http://www.ndbc.noaa.gov/data/realtime2/41053.txt
I am proceding the following way,
clc,clear all
fid = urlwrite('http://www.ndbc.noaa.gov/data/realtime2/41053.txt','SJ.txt'); % URL from CARICOOS
Data = SJ;
Time = Data{1,1};
The following is the function code,
function Data = SJ
fid = fopen( 'SJ.txt' );
Data = 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
I keep getting this error,
Error in ==> SJ at 3
end
??? Output argument "Data" (and maybe others) not assigned during call to
"C:\Users\User\Documents\MATLAB\CARICOOS\SJ.m>SJ".
Error in ==> SJ_F at 4
Data = SJ;
  1 件のコメント
Walter Roberson
Walter Roberson 2013 年 2 月 17 日
To check: is your variable name assigned to by the textscan() exactly the same as the variable name on the left side of the "=" in your "function" line? It looks like it is in what you posted, but please confirm in your original source.
You will probably have to put a breakpoint in at the textscan line, and check the value of "fid" and step once to have the textscan() executed, then check the workspace to confirm that it was assigned.

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeText Files についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by