Solve BVP with datapoints as input variable
Mostrar comentarios más antiguos
Hello,
I have been trying to solve first order coupled differential equations in which both of my differential equations have variables (alpha_e and alpha_h) as an input. The variables are simulated results, and thus I have values not an equation to represent these variables. When I generate a fit equation and use them directly then I can solve it. But finding an equation to fit the data is not always possible, so I need to use the values directly/some other way (defining a function using fit command), but nothing seems to work except for equation. I am getting 'Not enough input arguments' when I am trying with fit function. I am using BVP5c solver. Please help.
Here are the equations and the codes that I am working with. If you run the code, you will see the expected results, but if you use the ones defined by 'fit' (bold) will return: 'Not enough input arguments'

Codes:
solinit = bvpinit(y, @guess);
sol = bvp5c(@odefun, @bcfun, solinit);
function dpdy = odefun(y,p, e,h, ealpha, halpha)
% ealpha = fit(y, e, 'linearinterp', 'Normalize', 'on');
% halpha = fit(y, h, 'linearinterp', 'Normalize', 'on');
ealpha = ((140800*exp(-((y-0.17)/0.008511).^2)+112300*exp(-((y-0.1832)/0.01434).^2)-186.6*exp(-((y-0.06409)/1.297).^2)+3531000*exp(-((y-0.2225)/0.02767).^2)+70120*exp(-((y-0.2767)/0.05906).^2)-3416000*exp(-((y-0.2227)/0.02722).^2)));
halpha = ((53050*exp(-((y-0.1616)/0.009634).^2)-12310*exp(-((y+42.82)/18.3).^2)+12320*exp(-((y-0.2441)/0.02159).^2)+49680*exp(-((y-0.1774)/0.01608).^2)+50640*exp(-((y-0.2046)/0.02749).^2)+33.49*exp(-((y-0.06427)/0.04413).^2)+21050*exp(-((y-0.2638)/0.05081).^2)));
dpdy = zeros(2,1);
dpdy(1) = (1-p(1)).*(ealpha./10000).*(p(1)+p(2)-p(1).*p(2));
dpdy(2) = -(1-p(2)).*(halpha./10000).*(p(1)+p(2)-p(1).*p(2));
end
function res = bcfun(pa,pb)
res = [pa(1)
pb(2)];
end
function p = guess(y) % guess at solution behavior
p = [sin(y)
cos(y)];
end
10 comentarios
Torsten
el 26 de Ag. de 2022
You don't need to use bvp5c.
The solution is obviously P_e = P_h = 0 for all y.
Mohammad Rezaul Islam
el 26 de Ag. de 2022
No. This is the solution. Why do you think that?
Because P_e = P_h = 0 solves your differential equations and your boundary conditions.
Maybe there is more than one solution, but usually in such cases there are infinitly many, and numerical methods are senseless to apply.
Mohammad Rezaul Islam
el 26 de Ag. de 2022
There is one unique solution depending on the values of alpha_e and alpha_h, as far as I understand.
Then you didn't understand that P_e = P_h = 0 is always a solution - whatever ealpha and halpha are. So there is no unique solution for your system.
However, from Matlab/coding point of view, can anyone help me with a proper definition of ealpha and halpha that will allow the 'odefun' to execute without an error and producing a result?
Use MATLAB's "interp1" with method = spline on your data for alpha_e and alpha_h instead of "fit".
Mohammad Rezaul Islam
el 26 de Ag. de 2022
Mohammad Rezaul Islam
el 28 de Ag. de 2022
Mohammad Rezaul Islam
el 28 de Ag. de 2022
Mohammad Rezaul Islam
el 28 de Ag. de 2022
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Boundary Value Problems en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
