readmatrix "not enough input arguments"

I'm getting a really strange error when trying to use readmatrix() to load a .csv file. It tells me there's not enough input arguments!
d_obs = readmatrix(sprintf('%s/%s',NMR_path,NMR_obs_filename));
this is the command I'm using. The strange thing is that just last week, this worked perfectly, and I have not changed anything since then. If it is at all related, I also get a message "The import tool doesn't have access to read the file" when I try to open the file directly by double-clicking it in the current folder tab. I checked the files and they're not empty.
Anyone got some idea of what is going on here?

9 件のコメント

Walter Roberson
Walter Roberson 2020 年 11 月 26 日
編集済み: Walter Roberson 2020 年 11 月 26 日
Is it possible that NMR_path or NMR_obs_filename are empty?
What shows up for
which -all readmatrix
Frederikke Hansen
Frederikke Hansen 2020 年 11 月 26 日
The filenames are not empty, and I have also tried readmatrix('filename.csv') directly, with the same error.
I get the following:
>> which -all readmatrix
C:\Program Files\MATLAB\R2020b\toolbox\matlab\iofun\readmatrix.m
Ameer Hamza
Ameer Hamza 2020 年 11 月 26 日
Can you post the complete error message. Everything in red.
As a sidenote, the MATLAB's way to create complete path is something like this
d_obs = readmatrix(fullfile(NMR_path,NMR_obs_filename));
Frederikke Hansen
Frederikke Hansen 2020 年 11 月 26 日
Error using readmatrix (line 157)
Not enough input arguments.
Error in invert_logdist (line 31)
d_obs = readmatrix(fullfile(NMR_path,NMR_obs_filename));
Error in Generate_and_invert (line 84)
[x,T2dist,CI,resnorm,output]=invert_logdist(data,param,opt);
Ameer Hamza
Ameer Hamza 2020 年 11 月 26 日
The error occurs inside a try-catch block. Can you run the following line in the command window
dbstop if caught error
and then rerun your code. MATLAB will pause the code at the line where the error occurs. Show us the file and the line at which error occurs?
Star Strider
Star Strider 2020 年 11 月 26 日
Try this:
which invert_logdist -all
That might give some idea of what the problem is, since I very much doubt that readmatrix does any processing.
Also, please post the MATLAB release/version you are using.
Frederikke Hansen
Frederikke Hansen 2020 年 11 月 26 日
>> which invert_logdist -all
C:\Users\frede\Documents\MATLAB\NMR Project\Alt\Alternative Approach testing\Easy to use\invert_logdist.m
I'm using R2020b :)
Frederikke Hansen
Frederikke Hansen 2020 年 11 月 26 日
@Ameer Hamza
Star Strider
Star Strider 2020 年 11 月 26 日
What else is in the
C:\Users\frede\Documents\MATLAB\NMR Project\Alt\Alternative Approach testing\Easy to use\
directory?

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

 採用された回答

Ameer Hamza
Ameer Hamza 2020 年 11 月 26 日
編集済み: Ameer Hamza 2020 年 11 月 26 日

0 投票

You have defined a function name replace() placed on path
C:\...\Thesis\emi-matlab-master\EMI_Calibration\replace.m
which is shadowing the MATLAB's built-in function named replace(). Rename your function to something else.

2 件のコメント

Frederikke Hansen
Frederikke Hansen 2020 年 11 月 26 日
OH! This makes sense, the scripts in this folder are not written by me and I only recently added it to my directory. Thank you!
Ameer Hamza
Ameer Hamza 2020 年 11 月 26 日
I am glad to be of help!

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

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by