Borrar filtros
Borrar filtros

Why do I keep getting this error on function

1 visualización (últimos 30 días)
Juan Rosado
Juan Rosado el 18 de Dic. de 2012
I am trying to generate a function that creates an output of very extensive wave forecast data divided in cell array.
The code goes like this,
clc,clear all
fid = urlwrite('http://www.ndbc.noaa.gov/data/realtime2/41115.spec','Rincon.txt'); % URL from CARICOOS
cac = cssm(fid)
The function goes like this,
function cac = cssm()
fid = fopen( 'Rincon.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
I keep getting this error and don't know how to fix it, could you please help?
??? Error using ==> cssm
Too many input arguments.
Error in ==> ult1 at 4
cac = cssm(fid)

Respuesta aceptada

Wayne King
Wayne King el 18 de Dic. de 2012
Editada: Wayne King el 18 de Dic. de 2012
You need to define your function with the input argument
function cac = cssm(fid)
then pass the function the file identifier, don't put it inside your function.
Why do you have code like this:
fid = urlwrite('http://www.ndbc.noaa.gov/data/realtime2/41115.spec','Rincon.txt'); % URL from CARICOOS
cac = cssm(fid)
and then on line two of your function, you have
fid = fopen('Rincon.txt');
??
Either declare the function with NO input arguments
function cac = cssm
and do everything internally, or pass, the function the fid argument and get the file identifier before you call the function.

Más respuestas (0)

Categorías

Más información sobre Standard File Formats en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by