Anyone that can find what is wrong about the function?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Jenny Andersen
el 17 de Nov. de 2019
Comentada: Stephen23
el 19 de Nov. de 2019
It says " Not enough input values" but I can not see which values I have missed? Can you?
3 comentarios
Stephen23
el 19 de Nov. de 2019
"But if I want to be able to run the function (by clicking "Run"), how do I need to change my function to be able to achive this?"
You can either:
- write your function to have default values when input arguments are not supplied, or
- set up the "Run" button to provide specific input values when you call that function.
Which would you prefer?
Respuesta aceptada
Adam Danz
el 18 de Nov. de 2019
Editada: Adam Danz
el 18 de Nov. de 2019
"if I want to be able to run the function (by clicking "Run"), how do I need to change my function to be able to achive this?"
Sometimes functions can have default inputs when they are missing from the function-call. Here is an example of how to define default inputs to both of your input variables. The default inputs are defined with the function call is missing the inputs or if the inputs are empty. Sometimes it's good to incude warnings when assigning default inputs so you know when an input was missing. You can remove the warnings in this example, of course.
function [v2, v3] = OrtoVektorFunction(w3, w2)
% Default inputs
if nargin < 1 || isempty(w3)
w3 = 0;
warning('Default input used.')
end
if nargin < 2 || isempty(w2)
w2 = 1;
warning('Default input used.')
end
% Continue with code....
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Tables 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!