Solve for x given y and plot

15 vues (au cours des 30 derniers jours)
Lauren McCord
Lauren McCord le 20 Sep 2021
I solved a 2nd Order Differential Equation for the following answer:
y= (2 * e^((2*x)/3)) - ((7*x*e^((2x)/3))/3)
Now, given y=-4, I want to plot and find the value of x when the plot first crosses y=-4.

Réponse acceptée

Star Strider
Star Strider le 20 Sep 2021
Depending on what you wan, either use fzero or interp1
y = @(x) (2 * exp((2*x)/3)) - ((7*x.*exp((2*x)/3))/3);
x = linspace(0, 2);
yq = -4;
xq = fzero(@(x) y(x) + 4, 1)
xq = 1.4914
xq = interp1(y(x), x, -4)
xq = 1.4914
figure
plot(x, y(x))
hold on
plot(xq, yq, 'r+')
hold off
grid
xlabel('x')
ylabel('y')
.

Plus de réponses (0)

Catégories

En savoir plus sur 2-D and 3-D Plots dans Help Center et File Exchange

Produits


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by