Getting Error message when using backslash operator

12 vues (au cours des 30 derniers jours)
Austin Smith
Austin Smith le 1 Déc 2020
Commenté : Walter Roberson le 2 Déc 2020
I have tried to set up and use the backslash operator for a system of ODEs and am getting an error message. I think that I am not establishing my y values correctly but I'm not sure how to fix it.
  5 commentaires
Austin Smith
Austin Smith le 2 Déc 2020
I don't have a specific number for it yet since it represents a set of values that I haven't found yet. The purpose of my assignment is to find the value of y through those methods. I tried to remove y but then it requires an input argument for y still
Walter Roberson
Walter Roberson le 2 Déc 2020
All of the methods you are required to use for solving the ODE are numeric methods. You are not asked to find the formula that gives the answer over the time range: you are being asked to find numeric values at times between 0 and 4.
As such, the program you write cannot operate numerically on the idea that there is a variable y(1): it always needs a specific y(1) value.
Suppose I ask you to plot (x^2-1) over the range 0 to 4. You would probably say, "Okay, easy enough. 0^1-1 is..." -- and then I interrupt you and say, "No, no, I didn't say you could put in specific numeric values! You have to just plot using the idea that there is value to be plotted at, you cannot use any actual values!"
MATLAB needs actual numeric values for your function to process. Process particular set of numeric inputs, record the results, process another particular set of numeric inputs, process the results, and so on, and eventually graph the particular numeric values that you calculated.
It is the difference between having a recipe for making omlette (which tells you the steps you would use if you were to make an omlette) compare to actually cooking an omlette.
Recipe Step 1: get a green vegetable out of the refrigerator and clean it:
Actual cooking Step 1: look in the refrigerator and find all the green vegetables you have there and pick one specific one, and take it out of the refrigerator and clean it.
Running the omlette-cooking program needs the know the specific vegetable, not just the idea that there will be a vegetable.

Connectez-vous pour commenter.

Réponse acceptée

Steven Lord
Steven Lord le 2 Déc 2020
You've posted the dydtsys_practice function that implements the right-hand side of your system of ODEs, but to solve the system of ODEs you're not expected to call that function directly. Call an ODE solver (ode45 is usually a good first choice) and pass a function handle to your dydtsys_practice function into it as the first input argument. See the examples on the documentation page for ode45 for the syntax you need to use to call ode45 and create the function handle.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by