Symbolic matlab: how to set a variable as a function of time?

Hello to all! I'm trying to set a symbolic variable as a function of "t". This is because I need to obtain something like this:
K>> diff(sin(theta),t)
ans = diff(theta,t)*cos(theta)
or
ans= theta_dot*cos(theta)
but how to tell Matlab that variable theta is a function of time "t"?
Thank you!

답변 (4개)

Walter Roberson
Walter Roberson 2012년 2월 15일
syms theta t
diff(sin(theta(t)),t)

댓글 수: 2

In newer versions of MATLAB, you can use
syms theta(t)
diff(sin(theta),t)
Is it possible to make vector function of t? Something like this
sym('q(t)', [3 1])
diff(sin(q),t)

댓글을 달려면 로그인하십시오.

sharara rehimi
sharara rehimi 2018년 8월 16일

1 개 추천

thanks a lot..great for my problem
Wayne King
Wayne King 2012년 2월 15일
Hi Sebastian, do you know the expression for theta(t)?
syms theta t;
theta(t) = t^2;
diff(cos(theta),t)
Sebastian D'Amico
Sebastian D'Amico 2012년 2월 15일

0 개 추천

Wayne, thank you for your answer! I don't have the expression of theta because I don't need it. This is the reason I need to tell Matlab that theta is a function of "t" so, when derivate is computed, it should consider that, for example, diff(sin(theta),t) is equal to diff(theta,t)*cos(theta). But, how to set it?
Seabstian

댓글 수: 1

Do you really need that if you do not know the expression for theta(t), you know df(theta)/dt = df/dtheta*dtheta/dt

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Mathematics에 대해 자세히 알아보기

질문:

2012년 2월 15일

댓글:

2020년 6월 13일

Community Treasure Hunt

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

Start Hunting!

Translated by