Solving differential equation that includes an (extra) unknown function
이전 댓글 표시
I am trying to find a solution for
in the below differential equation:

The non-constant emission rate is the "unknown function" mentioned in the question title. Stating that the function that governs emission rate is unknown is somewhat inaccurate as I have a vector containing values for emission for every examined time t.
Besides knowing values for R at given times t, we know that
and that
.
and that
.I am in the process of writing a small Matlab script, and therefore I am hoping to find a solution on a form that allows implementation and evaluation at given points in time (corresponding to the values in known vector R).
I have tried using Matlab’s dsolve function to get an expression for
:
:syms c(t) r(t) v q
ode = diff(c) == r/v - q*c/v;
cond = c(0)==0;
expr = dsolve(ode,cond);
And Matlab derives the following expression:
expr =
exp(-(q*t)/v)*int((exp((q*x)/v)*r(x))/v, x, 0, t, 'IgnoreSpecialCases', true, 'IgnoreAnalyticConstraints', true)
Which I translate to:
However, this expression considers
as a continuous function and will not be implemented easily. I have tried and failed. Below is a snippet from my code along with excerpts from the error messages; I have attached the full .m file in case anybody wants to look.
intfun = @(x,N,step,R,V) exp(N*(x-1)*step*60)*R(x)/V;
r(1) = 0; r(i+1) = R(i);
Cat(i) = integral(@(x)intfun(x,N,step,r,V),i,i+1);
Ca(i) = exp(-N*t(i))*sum(Cat(1:end));
Error in VOC2003XuYang2 (line 60)
Cat(i) = integral(@(x)intfun(x,N,step,r,V),i,i+1);
Subscript indices must either be real positive integers or logicals.
The error message puzzles me: it indicates that I fail at supplying proper values (not integers in possible interval) for indexing in R. I cannot find the error. So, I have started to believe that the integral function might not allow changes in certain variables – which may make some mathematical sense. Either way, I am stumped. And I am stuck. So I come here in search for help.
I have three questions:
- Can anybody help me find a simpler (explicit and fully analytical) solution for
that is easy to implement? - Can anybody help me fix my code (assuming that what I have been trying is even possible)?
- Or can anybody suggest an alternative approch to the problem, e.g. some function or series of functions that can get me to a solution for
?
Thanks!
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Mathematics에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!