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

1 回表示 (過去 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 Center および File ExchangeSurface and Mesh Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by