Getting Error message when using backslash operator
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Austin Smith
il 1 Dic 2020
Commentato: Walter Roberson
il 2 Dic 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.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/438218/image.png)
5 Commenti
Walter Roberson
il 2 Dic 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.
Risposta accettata
Steven Lord
il 2 Dic 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.
0 Commenti
Più risposte (0)
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!