Symbolic rewritten in matlab

조회 수: 1 (최근 30일)
Miraboreasu
Miraboreasu 2022년 6월 21일
댓글: Walter Roberson 2022년 6월 21일
alpha=log(r)/t0/(r-1);
beta=r*log(r)/t0/(r-1);
p0=p*(exp(-alpha*t)-exp(-beta*t))/(exp(-alpha*t0)-exp(-beta*t0));
%r=?
%I tried this, plug alpha and beta with the expressions
syms r t p p0 t0
alpha=log(r)/t0/(r-1);
beta=r*log(r)/t0/(r-1);
%p0=p*(exp(-(log(r)/t0/(r-1))*t)-exp(-(r*log(r)/t0/(r-1))*t))/(exp(-(log(r)/t0/(r-1))*t0)-exp(-(r*log(r)/t0/(r-1))*t0));
eqn=(p*(exp(-(log(r)/t0/(r-1))*t)-exp(-(r*log(r)/t0/(r-1))*t))/(exp(-(log(r)/t0/(r-1))*t0)-exp(-(r*log(r)/t0/(r-1))*t0))==p0);
r=solve(eqn,[t, p, p0 t0])
%It doesn't give what I want
Hello, I have a equation, p0= above
I want to rewrite it as r=something
how can I do this in MATLAB or any other website?
  댓글 수: 1
Walter Roberson
Walter Roberson 2022년 6월 21일
You cannot solve one equation for four variables. You should be trying
solve(eqn, r)

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

채택된 답변

Star Strider
Star Strider 2022년 6월 21일
An analytic solution is likely not possible, due to the nature of the expression.
The only option is to solve it numerically for ‘r’ given appropriate values for the other variables —
syms p p0 r t0 t
alpha=log(r)/t0/(r-1);
beta=r*log(r)/t0/(r-1);
Eqn = p0 == p*(exp(-alpha*t)-exp(-beta*t))/(exp(-alpha*t0)-exp(-beta*t0))
Eqn = 
p0fcn = matlabFunction(rhs(Eqn)-p0)
p0fcn = function_handle with value:
@(p,p0,r,t,t0)-p0-(p.*(exp(-(t.*log(r))./(t0.*(r-1.0)))-exp(-(r.*t.*log(r))./(t0.*(r-1.0)))))./(exp(-(r.*log(r))./(r-1.0))-exp(-log(r)./(r-1.0)))
p = rand;
p0 = rand;
t = rand;
t0 = rand;
r = fsolve(@(r)p0fcn(p,p0,r,t,t0), rand)
No solution found. fsolve stopped because the relative size of the current step is less than the value of the step size tolerance squared, but the vector of function values is not near zero as measured by the value of the function tolerance.
r = -0.0174
.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Symbolic Math Toolbox에 대해 자세히 알아보기

태그

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by