Azzera filtri
Azzera filtri

Insufficient number of outputs from right hand side of equal sign to satisfy assignment.

24 visualizzazioni (ultimi 30 giorni)
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)

Risposta accettata

Timothy Dunning
Timothy Dunning il 19 Apr 2023
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
  2 Commenti
Walter Roberson
Walter Roberson il 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

Accedi per commentare.

Più risposte (2)

Walter Roberson
Walter Roberson il 18 Apr 2023
Spostato: Walter Roberson il 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 Commenti
Walter Roberson
Walter Roberson il 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.
Timothy Dunning
Timothy Dunning il 19 Apr 2023
I dont get the error when i run that line of code in the command window. does that help?

Accedi per commentare.


Matt J
Matt J il 18 Apr 2023
Modificato: Matt J il 18 Apr 2023
Possibly, you've done something like this within the method() function:
out={1,2};
[a,b,c]=out{:}
Insufficient number of outputs from right hand side of equal sign to satisfy assignment.

Categorie

Scopri di più su Startup and Shutdown in Help Center e File Exchange

Prodotti


Release

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by