If Statement In ode45() With Symbolic Variables

조회 수: 1 (최근 30일)
Rafael Fehér
Rafael Fehér 2020년 12월 9일
댓글: Rafael Fehér 2020년 12월 10일
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
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?
Rafael Fehér
Rafael Fehér 2020년 12월 10일
Hi, Mr. Roberson. Thank you for your reply.
Alpha is a parameter of the system. It is calculated as follow, for each time step:
As varies at each time step of the simulation, so does α. U is the velocity of the incoming flow.

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Symbolic Math Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by