How can I fix my graph and add a slider to it?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Danny Allen
el 22 de Jun. de 2020
Respondida: Walter Roberson
el 22 de Jun. de 2020
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.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/320035/image.png)
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])
0 comentarios
Respuesta aceptada
Walter Roberson
el 22 de Jun. de 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.
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Surface and Mesh Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!