MATLAB Answers

error using fopen-- too many input arguments

8 views (last 30 days)
Kartik on 8 Feb 2014
Edited: dpb on 8 Feb 2014
i wanted to make a thermocouple database data file in matlab. So i downloaded the tables from the its-90 website and used the following code to acquire and read the data is a text doc containing thermocouple data.
tcdata=readstdtcdata(''); save thermocouple_its90.mat tcdata;
It gives the following error:-
??? Error using ==> fopen Too many input arguments.
Error in ==> readstdtcdata at 89 f = fopen(filename,'r', 'n', 'ISO-8859-1');
So what should i do.Is there any way to counter this issue

Accepted Answer

dpb on 8 Feb 2014
Edited: dpb on 8 Feb 2014
??? Error using ==> fopen Too many input arguments.
Error in ==> readstdtcdata at 89 f = fopen(filename,'r', 'n', 'ISO-8859-1');
The fourth optional argument to fopen (ENCODING) is a relatively recent introduction; I'm not sure precisely which version of Matlab introduced it. I have R12 and R2012b here; it's not in R12 but is in R2012b so somewhere in between (which is a pretty wide spell, granted).
If you can't upgrade your version, then the only fix is to edit the m-file for readstdtcdata and remove the 'ISO-8859-1' argument. It's highly unlikely you need it anyway.
dpb on 8 Feb 2014
function tc = readstdtcdata(filename)
%READSTDTCDATA read NIST STD DB 60 ITS-90 thermocouple data file
tc = [];
% --- Open ITS-90 text/data file
f = fopen(filename,'r', 'n', 'ISO-8859-1');
So, you've got it; make an edit and resave it or rename a copy of it to something else and use that instead...
f = fopen(filename,'r', 'n');
Is what you need instead for an earlier version of Matlab.
Or, of course, you could bury a version test in there as well and execute conditionally or a try...catch block--
f = fopen(filename,'r', 'n', 'ISO-8859-1');
f = fopen(filename,'r', 'n');
It's either that or upgrade or use another tack entirely.
I hadn't noticed it was a TMW-supplied file; interesting. Despite that and the hope that they would have self-consistent Toolboxen with the main release, clearly from the error message your version of base Matlab does not support the fourth (ENCODING) argument to fopen.
What does ver return on your system?
Oh, or another thought -- isn't any chance there's an out-of-date version of fopen hanging around is there? What does
which fopen
And, of course, what does
help fopen
show for number of possible arguments? It'll simply be
as the most number of parameters (from my R12 doc) rather than the
in the following (new) paragraph in the R2012b doc's; said section not existing in R12.
Again, there's your apparent problem; the function expects a later version of fopen than your installation.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!