d solve command matlab
5 次查看(过去 30 天)
显示 更早的评论
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
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 个评论
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
2024-10-4
编辑:John D'Errico
2024-10-4
syms e P S A t m V0 t0 V(t) real
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
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
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
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
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!