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.
23 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Timothy Dunning
el 18 de Abr. de 2023
Comentada: Timothy Dunning
el 19 de Abr. de 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 comentarios
Respuesta aceptada
Timothy Dunning
el 19 de Abr. de 2023
2 comentarios
Walter Roberson
el 19 de Abr. de 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
Más respuestas (2)
Walter Roberson
el 18 de Abr. de 2023
Movida: Walter Roberson
el 18 de Abr. de 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 comentarios
Walter Roberson
el 18 de Abr. de 2023
Or.... possibly the problem is happening somewhere inside method and you did not show us the complete error message and the appropriate code.
Ver también
Categorías
Más información sobre Entering Commands en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!