How can I take the time derivative of a function?
8 次查看(过去 30 天)
显示 更早的评论
I'm trying to solve a 1 DOF second order differential equation for theta(t),
theta_dd(t) = -(m1*g*sin(theta)+T2*sin(theta+beta)+m1*x_dd(t))/(m1*l1)
where beta and T2 are both function of theta, and x_dd(t) is a forcing function.
beta = @(theta) asin((l1/l2)*sin(theta));
T2 = @(theta) (m2*ydd+c*yd+k1*y+m2*g)./cos(beta(theta));
T2 is dependent on ydd(t), yd(t), y(t), and beta, again all of which are dependent of theta(t). My question is are how I can use matlab to define the first and second derivative of y(t).
y = @(theta) l1*(1-cos(theta))+l2*(1-cos(beta(theta)));
yd = @(theta) ...;
ydd = @(theta) ...;
I'm going to run this on simulink but i need to provide a function for T2.
Some have recommended using the symbolic toolbox but I'm not sure where to start.
0 个评论
回答(1 个)
Guru Mohanty
2020-5-8
Symbolic toolbox can be used in your case. To do this you need to do the following steps.
Here is a sample code for it.
syms theta
beta = asin((11*sin(theta))/12);
y = 11*(1-cos(theta))+12*(1-cos(beta))
yd = diff(y ,theta)
ydd = diff(yd ,theta)
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Symbolic Math Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!