Why do I keep getting this error on function
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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)
0 comentarios
Respuesta aceptada
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)
Ver también
Categorías
Más información sobre Low-Level File I/O en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!