Cro*_*oCo 3 matlab symbolic-math derivative
假设我有这个功能
f(t) = 4*sin(a(t)) + x(t)*y(t) + h + cos(y(t))*sin(x(t))
Run Code Online (Sandbox Code Playgroud)
我如何根据时间计算其衍生物?
您需要将变量及其中的函数声明为符号,然后使用diff:
clear
clc
syms a x y t h
a(t) = symfun(sym('a(t)'), t)
x(t) = symfun(sym('x(t)'), t)
y(t) = symfun(sym('y(t)'), t)
F = 4*sin(a(t)) + x(t)*y(t) + h + cos(y(t))*sin(x(t))
DerF_t = diff(F,t)
Run Code Online (Sandbox Code Playgroud)
给出以下(杂乱)输出:
F = h + 4*sin(a(t)) + cos(y(t))*sin(x(t)) + x(t)*y(t)
DerF_t = x(t)*diff(y(t), t) + y(t)*diff(x(t), t) + 4*cos(a(t))*diff(a(t), t) + cos(x(t))*cos(y(t))*diff(x(t), t) - sin(x(t))*sin(y(t))*diff(y(t), t)
Run Code Online (Sandbox Code Playgroud)
需要注意的是由于(T),X(t)和y(t)的简单定义为功能"T",我们坚持自己的"象征性的"衍生物(我不知道抱歉术语)...例如,diff(a(t)).
希望这是你所追求的!