dlmwrite gives error message Too many output arguments.

Dear Sir/Madam,
I have installed Matalb2018b on my Mac OSX 10.13.6. I am trying to use the function dlmwrite but it gives the error message: Too many output arguments. I am using a simple example from the dlmwrite help page. Please follow the commands given in the Command Windows:
>> M = magic(3);
>> dlmwrite dlmwrite('myFile.txt',M)
Error using dlmwrite (line 104)
Too many output arguments.
>>
>> dlmwrite("myFile.txt",M)
Error using dlmwrite (line 104)
Too many output arguments.
>>
>> which all dlmwrite
built-in (/Applications/MATLAB_R2018b.app/toolbox/matlab/ops/all)
>>
>> dbtype 'dlmwrite' 1
1 function dlmwrite(filename, m, varargin)
dlmwrite gives the "Too many output arguments" error message with Matlab 2018b and Matlab 2017b. Instead dlmwrite works fine with MAtlab 2016b and Matlab 2015a. All these versions are installed on this Mac.
Thank you

5 Comments

Do not just go through the motions of checking, you actually need to look at what you are doing:
>> which all dlmwrite
built-in (/Applications/MATLAB_R2018b.app/toolbox/matlab/ops/all)
% ^^^^ what is this?
Look at the second line: is that really the function you wanted to check? Or did you use the wrong syntax for which and actually checked the function all ? (hint: you used the wrong syntax).
Show us the output of this command:
which dlmwrite -all
% ^ you forgot this! Check the documentation.
Is
>> dlmwrite dlmwrite('myFile.txt',M)
a typo?
Yes, sorry it is a typo:
>> dlmwrite('myFile.txt',M)
Error using dlmwrite (line 104)
Too many output arguments.
[MOVED from section for answers] Davide wrote:
Right, sorry
Here is the output of the command you suggested
>> which dlmwrite -all
/Applications/MATLAB_R2018b.app/toolbox/matlab/iofun/dlmwrite.m
Jan
Jan on 22 Jan 2019
Edited: Jan on 22 Jan 2019
Okay, than you are using the original version of dlmwrite. I assume, you have shadowed another function, which is called from inside dlmwrite. You can find this out using the debugger - see my answer.
By the way, thank you for saluting "Madams" explicitly. There are to many "hello guys" in this forum. :-)

Sign in to comment.

 Accepted Answer

Use the debugger. It is the best friend of the programmer.
dlmwrite stops in line 104. This is the error handling part of a TRY/CATCH block. To catch an error inside such a block, type this in the command window:
dbstop if caught error
% or
dbstop if all error
Now dlmwrite will stop in the failing line. Maybe you have redefined iscell, cell2mat, error, message, parseinput, isnumeric, ischar strrep, .... The failing line will reveal this.
If the problem is really a redefintion, you can use this tool to detect collisions with built-in functions: File Exchange: UniqueFuncNames

4 Comments

Many thanks!!!! It worked out.
I had a conflict between the built-in function (/Applications/MATLAB_R2018b.app/toolbox/matlab/strfun/newline) and a non-built-in function having the same name ( newline.m) contained in a Matlab library provided by other users.
Thanks again
You are welcome. Such conflicts happen frequently, when different Matlab versions are used. Therefore UniqueFuncNames is a very important tool for me when I upgrade Matlab or install some code in a foreign lab. To my surprise this tool is not popular in the FileExchange.

Sign in to comment.

More Answers (0)

Products

Release

R2018b

Asked:

on 22 Jan 2019

Commented:

on 22 Jan 2019

Community Treasure Hunt

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

Start Hunting!