Solve for x given y and plot

15 views (last 30 days)
Lauren McCord
Lauren McCord on 20 Sep 2021
Answered: Star Strider on 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.

Accepted Answer

Star Strider
Star Strider on 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')
.

More Answers (0)

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Products


Release

R2020b

Community Treasure Hunt

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

Start Hunting!