Getting Error message when using backslash operator

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 Comments

When you run that code, what numeric value are you expecting y(1) to have? I do not mean "describe in general terms what the purpose of y(1) is": I mean what specific numeric value do you expect it to have? 181.932432 ? -5.25623 ? And why that specific numeric value? What is your expectation of how MATLAB is to know that you want to use 654.321 this time or 98765.321 the next time you run the code?
The problem has nothing to do with the \ operator by the way.
So the y values are intended to create a vector to be able to be used in a different program where I can use them to solve for y using the methods listed in my screenshot here. The screenshot shows the main idea of what I'm trying to accomplish. I guess the y values are more symbolic than anything.
I specifically wrote,
I do not mean "describe in general terms what the purpose of y(1) is"
I mean what specific numeric value do you expect it to have?
I do not what to know what purpose you think y(1) has. You are asking to execute the code, and when you execute that code, y(1) has to have a specific numeric value. The very first time you execute the function, what exact value to you intend y(1) to have, and how do you expect MATLAB to know that is the exact value you want?
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
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.

Sign in to comment.

 Accepted Answer

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.

More Answers (0)

Categories

Find more on General Applications in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!