If Statement In ode45() With Symbolic Variables
1 次查看(过去 30 天)
显示 更早的评论
I have the following system of two Second-Order ODEs:
syms q(t) y(t)
structure_oscillator = diff(y,2) == -2 * zeta * diff(y) - y...
+ U(j)^2 / (4 * pi^2 * mass_ratio) * f * (q - 2 * pi * diff(y) / U(j)) +...
U(j)^2 * CFy / (4 * pi^2 * mass_ratio);
where zeta, mass_ratio and f are constants; U is a velocity vector and CFy varies in each time step.
wake_oscillator = diff(q,2) == 2 * beta * ni * diff(q) * (1 - 4 * f^2 / CLo^2 * q^2)...
- ni^2 * q + lambda * diff(y,2) + ni^2 * 2 * pi * diff(y) / U(j);
where beta, ni, CLo and lambda are constants.
I solved these equations with:
[V,S] = odeToVectorField(structure_oscillator, wake_oscillator);
M = matlabFunction(V,'vars',{'t','Y'});
sol = ode45(M,[0 250],[0.01 0 0 0]);
The problem is: CFy is determined by polynomials as function of an angle α. These polynomials varies depending on α (I used spline to fit the curve, and it gaves me 13 breaks). So, for each value of α I need an If to determine which equation to use to calculate CFy.
How can I introduce a If statament to calculate CFy as α varies?
Thank you,
Rafael F.
2 个评论
Walter Roberson
2020-12-9
is alpha effectively constant for any one run, a parameter to the system? or is it something that varies dynamically on external stimulus outside of the current variables? or does it vary dynamically with some of the variables?
回答(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!