d solve command matlab

조회 수: 5 (최근 30일)
Kees
Kees 2024년 10월 4일
댓글: John D'Errico 2024년 10월 5일
hello i just started programmig with matlab and encountered this error :
Error using symengine (line 58)
Could not extract differential variables to solve for. Use 'solve' or 'vpasolve' to compute the solutions of
non-differential equations.
Error in mupadengine/feval (line 155)
symengine('error',S(8:find(S=='[',1)-2));
Error in dsolve>mupadDsolve (line 328)
T = feval(symengine,'symobj::dsolve',sys,x,options);
Error in dsolve (line 189)
sol = mupadDsolve(args, options);
Error in hwbrownwk202016 (line 6)
solve = simplify(dsolve([diffeq,IC],symvar(V(t))))
this is the program
clear all
syms e P S A t m V0 t0 V(t) real
Warning: Can only make assumptions on variable names, not 'V(t)'.
IC = V(0)==V0
diffeq = diff(V(t),t) == P + e*V(t) - m*(S-(V(t)))
solve = simplify(dsolve([diffeq,IC],symvar(V(t))))
the program work in the online version but not in 2013...anybody knows wat the problem is?
  댓글 수: 3
Kees
Kees 2024년 10월 4일
hello Rahul, great and thanx! spend hours on this but in the end it was just a syntax difference between the old en new version..
John D'Errico
John D'Errico 2024년 10월 5일
Um, you can still use the "old" syntax, as I show how to do so in my answer. It is completely valid in the current release.

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

답변 (2개)

John D'Errico
John D'Errico 2024년 10월 4일
편집: John D'Errico 2024년 10월 4일
syms e P S A t m V0 t0 V(t) real
Warning: Can only make assumptions on variable names, not 'V(t)'.
The point being that assumptions can apply only to variables, not functions. V(t) is a function of t.
IC = V(0)==V0
diffeq = diff(V(t),t) == P + e*V(t) - m*(S-(V(t)))
Next, NEVER name a variable solve!!!!!!!!!
You will be using the FUNCTION solve at aoms point intime. NAming a variable will just have you soon be posting an anguished question, asking why the solve function does not work for you.
Just call simplify with two arguments, and not inside brackets.
Vsol = simplify(dsolve(diffeq,IC))
solve =
(S*m - P + exp(t*(e + m))*(P + V0*e - S*m + V0*m))/(e + m)
  댓글 수: 1
John D'Errico
John D'Errico 2024년 10월 4일
Answers is still not working properly, in terms of displaying results. So I had to paste in the result from my own command window.

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


Rahul
Rahul 2024년 10월 4일
Hi Kees,
I believe you are trying to solve differential equations for a particular solution, involving symbolic variables and their abstract functions.
In order to use the function “diff” correctly, ‘V(t)’ can be referred to as an arbitrary symbolic function, i.e., a function with no definition. Here, the function's name is ‘V’ (like a function handle) and it is represented by the abstract formula 'V(t)', which just means that it's a function of t. When you want to take the derivative of an abstract function, pass in the name of the function, in your case, ‘V’. While evaluating the function you can use the formula, e.g., V(0), the output of which is a ‘sym’ rather than a ‘symfun’.
Here is how you restructure your code snippet:
clear all
syms e P S A t m V0 t0 V(t) real
Warning: Can only make assumptions on variable names, not 'V(t)'.
IC = V(0)==V0
diffeq = diff(V,t) == P + e*V(t) - m*(S-(V(t)))
solve = simplify(dsolve([diffeq,IC],symvar(V(t))))
To know more about the usage of symbolic differentiation using "diff" function in MATLAB R2013a, you can use the following commands:
help sym/diff
doc sym/diff

카테고리

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

제품


릴리스

R2013a

Community Treasure Hunt

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

Start Hunting!

Translated by