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

 採用された回答

Walter Roberson
Walter Roberson 2016 年 1 月 30 日
編集済み: Walter Roberson 2016 年 1 月 30 日

0 投票

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 件のコメント

Brooke Sarley
Brooke Sarley 2016 年 1 月 30 日
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)
Walter Roberson
Walter Roberson 2016 年 1 月 30 日
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 = ' ';
...

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeDesign and Simulate SerDes Systems についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by