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

조회 수: 2 (최근 30일)
Danny Allen
Danny Allen 2020년 6월 22일
답변: Walter Roberson 2020년 6월 22일
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])

채택된 답변

Walter Roberson
Walter Roberson 2020년 6월 22일
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개)

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by