Parse error when using importfile?

I'm trying to import data from a .csv file (either one) into a matrix. I'm getting a "parse error" at line 1:
function waxsexposures = waxsimport('waxs_exposures_2015', 1, inf)
This is of the form
waxsexposures = importfile('waxs_exposures.par', startRow, endRow)
I've tried the following:
waxsexposures = waximport('waxs_exposures_2015')
---return--->Not enough input arguments.
waxsexposures = waximport('waxs_exposures_2015.par')
---return--->Unexpected MATLAB operator.
function waxsexposures = waxsimport(waxs_exposures_2015, startRow, endRow)
%%Initialize variables.
delimiter = ' ';
if nargin<=2
startRow = 1;
endRow = inf;
end

 Respuesta aceptada

Walter Roberson
Walter Roberson el 30 de En. de 2016
Editada: Walter Roberson el 30 de En. de 2016
Leave off the "function" when you invoke. You should use the code like you have at the bottom but to test it you should be using
waxsexposures = waxsimport('waxs_exposures_2015', 1, inf)
at the command line, without the word "function".

2 comentarios

Brooke Sarley
Brooke Sarley el 30 de En. de 2016
Thank you. Now it's returning Attempt to execute SCRIPT waxsimport as a function: C:\Users\...\waxsimport.m
Error in waxsimport (line 1) waxsexposures = waxsimport('waxs_exposures_2015.par', 1, inf)
No, the file needs to start with
function waxsexposures = waxsimport(waxs_exposures_2015, startRow, endRow)
but you need to invoke it from outside the function, and the invocation in that other routine would look like
waxsexposures = waxsimport('waxs_exposures_2015', 1, inf)
Or is your intent to provide "default" values if the user did not specify any inputs? If that was what you were trying to do then you would use a different form: you would use
function waxsexposures = waxsimport(waxs_exposures_2015, startRow, endRow)
if nargin < 1
waxs_exposures_2015 = 'waxs_exposures_2015';
end
if nargin < 2
startRow = 1;
end
if nargin < 3
endRow = inf;
end
delimiter = ' ';
...

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Design and Simulate SerDes Systems en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 30 de En. de 2016

Comentada:

el 30 de En. de 2016

Community Treasure Hunt

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

Start Hunting!

Translated by