Solve for x given y and plot

조회 수: 12 (최근 30일)
Lauren McCord
Lauren McCord 2021년 9월 20일
답변: Star Strider 2021년 9월 20일
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.

채택된 답변

Star Strider
Star Strider 2021년 9월 20일
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')
.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by