How can I fix my graph and add a slider to it?

2 views (last 30 days)
I plotted my solution to the following ode: , however, when I graph it I don't get a full set of values. What I mean is that I graphed the same solution on a different program and got a slightly different graph with more values. Is there any way I can adjust how I plot the values, or is this just an alteration within Matlab itself.
I've also tried adding a slider, however, every time I put in the code I just get a slider on a new figure that doesn't alter the C value within the graphed solution. How can I add a slider so when I move it, it changes the graph with the corresponding C value?
syms y(x);
eqn = 4*y-3*x+5*x*diff(y) == 0;
S = dsolve(eqn);
ezplot(S,[-10 10])

Accepted Answer

Walter Roberson
Walter Roberson on 22 Jun 2020
Your S ends up with two variables, one the obvious x, and the other being a constant representing the boundary condition. The name of that second variable is not fixed.
When you ezplot(S) it looks at the list of variables involved in S, sees that there are two, and chooses the first one alphabetically to be the independent variable, and the second one to be the dependent variable. Then it proceeds to plot the implicit equation where the function equals 0.
This is not the same as you would get if you were to fix a particular boundary condition and use x as the independent variable and S as the output dependent variable.
You can use
fsurf(S, [-1 1 1/10 1])
The -1 1 would be controlling the boundary condition, C*, and the 1/10 1 would be controlling the x. The value of S increases rapidly as x decreases, so be careful in reducing the x boundary. Also if you permit x to be less than 0 then S is complex-valued but fsurf() will not warn you that it is dropping the imaginary component.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!