필터 지우기
필터 지우기

Solve a nonlinear equation with constrains

조회 수: 2 (최근 30일)
Miraboreasu
Miraboreasu 2022년 12월 15일
편집: Torsten 2022년 12월 16일
Hello,
clear
p0=1000e6;
t0 = 1e-6;
td = 1e-6;
t = t0 + td;
c = 5e6;
a = @(r)log(r)./(t0*(r-1.0));
b = @(r)a(r).*r;
func= @(r) p0*((exp(-a*t) - exp(-b*t))/(exp(-a*t0) - exp(-b*t0)))-c;
r=1.5;
roots = fzero(func,r)
my equation is the func.
where a and b are,
  댓글 수: 1
Bora Eryilmaz
Bora Eryilmaz 2022년 12월 15일
편집: Bora Eryilmaz 2022년 12월 15일
Your function "p(t)" (func in your code) is not a function of time since you are assigning a fixed scalar value to "t" in your code. So, func() is a function of r, with a fixed "t". So what you are really solving here is p(r) = 0 given fixed values for t, t0, a, b, c.
You will need to reformulate your problem.

댓글을 달려면 로그인하십시오.

채택된 답변

Torsten
Torsten 2022년 12월 15일
p0 = 1000e6;
t0 = 1e-6;
td = 1e-6;
t = t0 + td;
c = 7.5e8;
a = @(r)log(r)./(t0*(r-1.0));
b = @(r)a(r).*r;
func= @(r) p0*((exp(-a(r)*t) - exp(-b(r)*t))./(exp(-a(r)*t0) - exp(-b(r)*t0))) - c;
r = 0.001:0.1:10;
plot(r,func(r))
root1 = fzero(func,[0.001 0.75])
root1 = 0.5000
root2 = fzero(func,[1.1 2.5])
root2 = 2.0000
  댓글 수: 2
Miraboreasu
Miraboreasu 2022년 12월 15일
Thanks, but if I keep c=5e6, it won't work
Torsten
Torsten 2022년 12월 15일
편집: Torsten 2022년 12월 16일
Yes, because no roots exist. Plot the function, and you will see that it does not cross the r-axis.
Note for functions that only depend on one variable: First plot, then solve.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

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

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by