Too many output arguments.
Mostrar comentarios más antiguos
Hello people, I need some help with the error below:
Error using SpringendBallsB04>groundHeight
Too many output arguments.
Error in SpringendBallsB04>impactMap (line ...)
[~,groundSlope] = groundHeight(horizPos);
Error in SpringendBallsB04 (line ...)
[IC, ballRolling]= impactMap(impactState,P); %This becomes the new start state
HERE IS A PART OF THE PROGRAM. THE FUNKTION CALLED impactMap BELOW THE MAIN CODE MIGHT BE THE PROBLEM.
I AM TRYING TO MAKE A 3D SIMULATION OUT OF A 2D CODE
PLEASE HELP ME
[code attached as a file by Madhan Ravi since it was too long]
Respuestas (1)
Srivardhan Gadila
el 11 de Abr. de 2020
The function z = groundHeight(x,y) in line 314 has only one output argument z and two input arguments x & y. You are calling this function in line 379 inside the function [stateOut, ballRolling] = impactMap(stateIn,P) as
[~,groundSlope] = groundHeight(horizPos);
Change it to
groundSlope = groundHeight(horizPos,2ndInputArgument);
5 comentarios
Jacob O. Otasowie
el 11 de Abr. de 2020
Jacob O. Otasowie
el 11 de Abr. de 2020
Srivardhan Gadila
el 21 de Abr. de 2020
@Jacob O. Otasowie, I think the error is self explanatory. Refer to y0 Input Argument explanation of the function ode45. It states that "Initial conditions, specified as a vector. y0 must be the same length as the vector output of odefun, so that y0 contains an initial condition for each equation defined in odefun." So make sure that the initial condition IC and the output of the function dynFunc are of same length.
Jacob O. Otasowie
el 22 de Abr. de 2020
Srivardhan Gadila
el 22 de Abr. de 2020
Refer to the following MATLAB Answers:
- https://mathworks.com/matlabcentral/answers/263409-error-when-function-returns-a-vector-of-length-2-but-the-length-of-initial-conditions-vector-is-4
- https://mathworks.com/matlabcentral/answers/380662-how-can-i-fix-this-error-func-returns-a-vector-of-length-2-but-the-length-of-initial-conditions-v
- https://mathworks.com/matlabcentral/answers/434994-how-can-i-solve-this-vector-lenght-problem
- https://mathworks.com/matlabcentral/answers/501899-ode45-to-solve-vector-ode
- https://mathworks.com/matlabcentral/answers/86020-what-s-means-this-error
Categorías
Más información sobre Programming en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!