replace expression of variables with an equivalent variable?

Hi,
how can i get back theta_v instead of omega*t + phi_v?
% Code
clearvars; clc;
syms Vx positive
syms theta_v phi_v
syms omega t positive
theta_v = omega*t + phi_v;
v = Vx*sin(theta_v)
y = diff(v, t)
subs(y,omega*t + phi_v, theta_v)

 採用された回答

Karan Gill
Karan Gill 2016 年 12 月 9 日

1 投票

Your substitution can't work because you defined "theta_v" to be "omega*t + phi_v". So you're just substituting "omega*t + phi_v" for the same thing. If you want to keep "theta_v" then don't define it as "omega*t + phi_v". Keep it as a symbolic function, and substitute in at the end.
>> syms x
>> syms theta_v(t)
>> syms Vx
>> v = Vx*sin(theta_v)
v(t) =
Vx*sin(theta_v(t))
>> y = diff(v, t)
y(t) =
Vx*cos(theta_v(t))*diff(theta_v(t), t)
>> syms omega phi_v
>> subs(y,theta_v, omega*t + phi_v)
ans(t) =
Vx*omega*cos(phi_v + omega*t)

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeSymbolic Math Toolbox についてさらに検索

質問済み:

2016 年 12 月 5 日

回答済み:

2016 年 12 月 9 日

Community Treasure Hunt

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

Start Hunting!

Translated by