0
Follow
0
View

# # The output of the system of ordinary differential equations I solved is struct character, may I ask how to set the output solution of the system of ordinary differential equations as A function syms z(t) [1,2]A=[-1,1

doxy1015 注册会员
2023-02-28 06:50

the reference answer GPT ᴼ ᴾ ᴱ ᴺ ᴬ ᴵ < br / > you can dsolve function form of converting the output function, so it can be used as ordinary functions. In this example, you can use the matlabFunction function to convert the parsing function in the structure into a function handle. Here is an example:

``````syms z(t) [1,2]
A=[-1,1;2,-2];
sol = dsolve(diff(z)==z*A,z(0)==[2,5]);

% 将解析函数转换为函数句柄
z1(t) = matlabFunction(sol.z1);
z2(t) = matlabFunction(sol.z2);

% 现在可以像使用普通函数一样使用 z1(t) 和 z2(t)
``````

## You can substitute z1(t) and z2(t) for sol.z1 and sol.z2, respectively, and then calculate the function value by entering the parameter t. For example, to calculate z1(0.5), you can use z1(0.5) to get the result.

Note: If you are going to use these functions in multiple files, you can save these functions as separate files so that they can be called as needed.

daisho0906 注册会员

Publish Time
2023-02-28 06:50
Update Time
2023-02-28 06:50