用MATLAB计算函数的二阶导数
我将按照以下步骤使用MATLAB计算函数的二阶导数-用MATLAB计算函数的二阶导数,matlab,derivative,Matlab,Derivative,我将按照以下步骤使用MATLAB计算函数的二阶导数- syms a b; th = sym('th(t)'); %th is a time dependent variable y = diff(a^2*cos(th)+(b/12)*sin(th)); thd = diff(th); %derivative of th wrt time ybythd = diff(y,thd); %derivative of y wrt thd p = diff(ybythd); %derivative of
syms a b;
th = sym('th(t)'); %th is a time dependent variable
y = diff(a^2*cos(th)+(b/12)*sin(th));
thd = diff(th); %derivative of th wrt time
ybythd = diff(y,thd); %derivative of y wrt thd
p = diff(ybythd); %derivative of ybythd wrt time
p
的值是p=diff(diff((b*cos(th(t))*diff(th(t),t))/12-a^2*sin(th(t))*diff(th(t),t),diff(th(t),t))
在上述结果中,我没有看到任何
d2th/dt2
项。这里出了什么问题?我认为您需要更明确地说明th
到底是什么。还有:这是您的完整代码吗?在R2014a车型上,diff
故障。如果你想做dy/dt
为什么不简单地使用p=diff(y,t)
?你也可以通过一次调用diff(…,t,2)
@knedlsepp:th
来做二阶导数,它可以是时间的任意函数。例如,可以考虑<代码> th>代码>作为摆线运动函数。这里的关键点是,th
将在所有计算完成后提供。上述代码在Matlab7.10.0.499(R2010a)版本中运行良好。如果需要的话,我可以提供屏幕截图。如果您以前清除了工作区,它是否也可以工作?这没有意义。dy/d(thd)
甚至是什么意思?你想用这些步骤计算什么?