Matlab Help Input argument undefined

In summary, the user is trying to solve an ODE in MATLAB using ODE45 solver, but is getting an error stating that the input argument "y" is undefined. They are asking for help and providing the code they are using. The potential issue is that they are not providing the matrices t and y when calling the function.
  • #1
matlabphd
2
0
Dear all. I am trying to solve an ODE in MATLAB using ODE45 solver. But the programe keep saying

? Input argument "y" is undefined.

Error in ==> lvv at 4
yprime=[a*y(1)-b*y(1)*y(2);-r*y(2)+c*y(1)*y(2)];

Can anybody be of help? Please.

The complete code is this:
function yprime=lvv(t,y)
%LV: Contains Lotka-Volterra equations
a=.5471;b=.0281;c=.0266;r=.8439;
yprime=[a*y(1)-b*y(1)*y(2);-r*y(2)+c*y(1)*y(2)];
[t,y]=ode45(@lvv,[0 20],[30;4])
plot(t,y(:,1))
Thanks
 
Physics news on Phys.org
  • #2
matlabphd said:
Dear all. I am trying to solve an ODE in MATLAB using ODE45 solver. But the programe keep saying

? Input argument "y" is undefined.

Error in ==> lvv at 4
yprime=[a*y(1)-b*y(1)*y(2);-r*y(2)+c*y(1)*y(2)];

Can anybody be of help? Please.

The complete code is this:
function yprime=lvv(t,y)
%LV: Contains Lotka-Volterra equations
a=.5471;b=.0281;c=.0266;r=.8439;
yprime=[a*y(1)-b*y(1)*y(2);-r*y(2)+c*y(1)*y(2)];
[t,y]=ode45(@lvv,[0 20],[30;4])
plot(t,y(:,1))
Thanks

When you call the function do you provide the matrices t and y? If not, the function does not know what y is.
 
  • #3
for reaching out for help with your ODE problem in MATLAB. It seems like the issue lies in the definition of your input arguments for the ODE solver. The error message suggests that the variable "y" is not being properly defined in your code. Have you declared "y" as a variable before using it in the function "lvv"? Additionally, make sure that the input arguments for the ODE solver match the function you are using (@lvv in this case). I recommend double-checking your code and making sure all variables are properly defined before running the program again. If the issue persists, please provide more information about your code so that I can further assist you. Best of luck with your ODE solving!
 

Related to Matlab Help Input argument undefined

1. What does the error "Input argument undefined" mean in Matlab?

This error means that the function or script you are trying to run requires a specific input argument, but you have not provided it. Matlab is unable to complete the operation without this required input.

2. How do I fix the "Input argument undefined" error in Matlab?

To fix this error, you need to provide the required input argument to the function or script. Check the documentation or code to determine what the input argument should be and make sure you are providing it correctly.

3. Why am I getting an "Input argument undefined" error even though I have provided all the necessary inputs?

This could be due to a variety of reasons such as misspelling the input argument, providing the inputs in the wrong order, or not properly defining the input argument in the code. Double check your inputs and the code to ensure everything is correct.

4. Can I have multiple input arguments for a Matlab function?

Yes, Matlab allows for multiple input arguments for a function. You can specify as many inputs as necessary for the function to run properly. Just make sure to provide all the required inputs in the correct order.

5. Is there a way to set a default value for an input argument in Matlab?

Yes, you can set a default value for an input argument in Matlab by using the syntax "inputArg = defaultValue" in the function definition. This will assign the default value to the input argument if no value is provided when the function is called.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
216
  • MATLAB, Maple, Mathematica, LaTeX
Replies
18
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
8
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
2K
Back
Top