필터 지우기
필터 지우기

solving trascendental equations, proper setting

조회 수: 1 (최근 30일)
PatrizioGraziosi
PatrizioGraziosi 2020년 6월 14일
댓글: Ameer Hamza 2020년 6월 17일
Hello everybody,
I'd like to solve for y = y(x) the following equation
d log( y ) / d x + y = 1 + f
with f = f(x).
f is a 1D numerically known array, I don't know its nalytical form.
I cannot set properly solve or fzero.
Can you help me, please?
Patrizio

채택된 답변

Ameer Hamza
Ameer Hamza 2020년 6월 14일
편집: Ameer Hamza 2020년 6월 14일
This is a differential equation and you can use symbolic toolbox to find an anayltical solution
syms y(x) f
eq = diff(log(y), x) + y == 1 + f;
sol = dsolve(eq);
Result
>> sol
sol =
(exp((C1 + x)*(f + 1))*(f + 1))/(exp((C1 + x)*(f + 1)) + 1)
f + 1
Following shows how to get a numerical solution using ode45
syms y(x) f
eq = diff(log(y), x) + y == 1 + f;
sol = dsolve(eq);
odeFun = matlabFunction(odeToVectorField(eq), 'Vars', {'t', 'Y', 'f'});
tspan = [0 10]; % time span for numerical solution
ic = 1; % initial condition: y(0)==1
fv = 1; % numerical solution for f=1
[t, y] = ode45(@(t, y) odeFun(t, y, fv), tspan, ic);
plot(t, y);
  댓글 수: 7
PatrizioGraziosi
PatrizioGraziosi 2020년 6월 16일
Hi Ameer,
you're solution is brilliant!
Sorry that I couldn't test it before... Your support has been excellent!
In the case we publish the data analysis done thanks to your solution, we'll aknowledge your support.
Thanks
Patrizio
Ameer Hamza
Ameer Hamza 2020년 6월 17일
I am glad that it worked for your case, and you got the results. Good luck with your research.

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

추가 답변 (0개)

카테고리

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

제품

Community Treasure Hunt

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

Start Hunting!

Translated by