Error using dsolve, System of differential Equations

2 次查看(过去 30 天)
Error:
Warning: Unable to find explicit solution.
> In dsolve (line 201)
In Nose_Differentiation (line 18)
Error using sym/subsindex (line 814)
Invalid indexing or function definition. Indexing must follow MATLAB indexing. Function
arguments must be symbolic variables, and function body must be sym expression.
Error in Nose_Differentiation (line 18)
[xSol(t), ySol(t), zSol(t)] = dsolve(odes,conds);
Code:
clear;
syms x(t) y(t) z(t);
cond1 = x(0) == 0;
cond2 = y(0) == 2;
cond3 = z(0) == 0;
conds = [cond1; cond2; cond3];
ode1 = diff(x) == y;
ode2 = diff(y) == -1*x + y*z;
ode3 = diff(z) == x*x - 4*y*y - 1;
odes = [ode1; ode2; ode3];
[xSol(t), ySol(t), zSol(t)] = dsolve(odes,conds);

回答(1 个)

Vidip
Vidip 2024-4-12
The error you're encountering arises from attempting to assign the output of ‘dsolve’ directly to function handles in a way that MATLAB doesn't support. When solving for multiple functions, ‘dsolve’ returns a structure by default. Alternatively, you can assign solutions to functions or variables directly by explicitly specifying the outputs as a vector where the ‘dsolve’ function only expects the equations to be passed as an input argument. You can refer to the below documentation link to get more information-

类别

Help CenterFile Exchange 中查找有关 Equation Solving 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by