Numerical differential equation solver for initial conditions not at y0
Show older comments
I've been trying to convert a part of mathematica code to a Matlab one, in order to integrate it for other calculations, but I am having some trouble getting the solver to run.
If by any chance this helps, this is the script that I am trying to convert:

And this is my approach.
syms Uf(t) delta y
d = 0.2000;
k_Karman = 0.4;
sol_Um = 3.2947;
omega = 0.5405;
Tp = 29.0823;
ks = 2.5 * d *10^-3 % [m]
k_Karman = 0.4 % von Karman constant
U_R04 = sol_Um * sin(omega*t)
U0_R04 = Uf/k_Karman*log(30*y/ks)
eq_R04 = sol_Um * sin(omega*t) == Uf/k_Karman*log(30*delta/ks)
sol_delta = solve(eq_R04,delta) % solve for delta
ME_R04 = int(diff(U0_R04,t),y,[0 sol_delta]) == sol_delta*diff(U_R04,t)-Uf^2
I believe that this far, I would be getting a matching result from the example below, however, I am unable to prepare the command line for the evaluation.
This was my initial attempt, but I have a feeling that is the wrong approach to take for this specific case as I am getting an error for the 'Vars' definition.
[VF,Sbs] = odeToVectorField(ME_R04);
Uffcn = matlabFunction(VF, 'Vars',{x,Y});
[x,Ufx] = ode15s(Uffcn, [0 Tp/2], 0);
Error using sym/matlabFunction>getOptions
The value of 'Vars' is invalid. 'Vars' value must be a character vector, a 1-dimensional cell array of character vectors, a 1-dimensional cell array of symbolic variables
or arrays of symbolic variables, or an array of symbolic variables.
Initial attempt was done for initial conditions of y0=0, as I am not aware of a way to define it the way mathematica script allows for Uf(0.001*Tp)=0.001*sol_Um
1 Comment
Rihards
on 6 Nov 2022
Accepted Answer
More Answers (0)
Categories
Find more on Mathematics 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!