If Statement In ode45() With Symbolic Variables
1 view (last 30 days)
Show older comments
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 Comments
Walter Roberson
on 9 Dec 2020
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?
Answers (0)
See Also
Categories
Find more on Symbolic Math Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!