method is the name of the function and also a variable stored in the script. Matlab cant call the function because it sees it as the variable
Insufficient number of outputs from right hand side of equal sign to satisfy assignment.
24 views (last 30 days)
Show older comments
Timothy Dunning
on 18 Apr 2023
Commented: Timothy Dunning
on 19 Apr 2023
Got the above error when trying to assign some variables from another function. the error occurs on line: [uInitial,xInitial,tInitial]=method(dtmin,xmax,dxmin,method,L);
and the method function, called, is defined:
function [u, x, t] = method(dt, xmax, dx, method,L)
0 Comments
Accepted Answer
Timothy Dunning
on 19 Apr 2023
2 Comments
Walter Roberson
on 19 Apr 2023
Yes, that can cause that problem.
These days, however, more typically MATLAB would notice if you tried to switch between using a name as a function and using a name as a variable, and would complain (in an unclear way.)
However, in the case where you assign to a name before the first place in the code that the name is intended to be used as a function call, and the defining function is not in the same file, then MATLAB is unable to tell that you intended a function call
More Answers (2)
Walter Roberson
on 18 Apr 2023
Moved: Walter Roberson
on 18 Apr 2023
The function method that you think you are calling in the statement
[uInitial,xInitial,tInitial]=method(dtmin,xmax,dxmin,method,L);
is not the same one that is defined with
function [u, x, t] = method(dt, xmax, dx, method,L)
For example, you might have a different function named method in your MATLAB path.
Or you might had a previous version of method that did not return as many as three outputs and you modified method since then to add more outputs, but MATLAB has not noticed that you modified method yet and is continuing to use the previous version of it.
The cases where MATLAB might not notice that you modified a file include:
- you modified a file using an external editor rather than the built-in editors. The built-in editors notify MATLAB when a file is modified but external editors do not.
- you might be using a function handle to a file and have modified the file; in such a case the function handle will not always notice and might continue to use the previous version.
- you might have stored method inside one of MATLAB's built-in directories. MATLAB never re-checks its built-in directories for changes, not unless it is specifically told to re-check them
For the first two cases, the trick is to clear the file name, such as clear method after modifying the file. The third case, where you stored the file inside MATLAB's installation directory... Don't Do That! rehash
2 Comments
Walter Roberson
on 18 Apr 2023
Or.... possibly the problem is happening somewhere inside method and you did not show us the complete error message and the appropriate code.
See Also
Categories
Find more on Startup and Shutdown in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!