Vector input to function handle for bvp4c
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hi,
I am trying to solve system of equations with bvp4c
res = @(y,res) [D_constant*(res(1)-res(2)); (U_numeric-(D_constant*(res(1)-res(2))))/C_constant; res(3);res(4)];
bc2 = @(T0,TH)[TH(3); TH(4);T0(1);T0(2)];
solinit= bvpinit(y_mesh, [1 0 1 0]);
sol2 = bvp4c (res,bc2,solinit);
In the function handle part; U_numeric is a vector with a dimension of (1 X number of meshes) which is solved before with another bvp4c.
In the res function handle, I want function handle to take U_numeric at corresponding location of y.(not a constant value). U_numeric is also dependent of y only (which is solved separately). How can i achieve this?
To be more specific, I have the solution of U_numeric which contains numbers at each position. Res is also a function dependent to position. I want U_numeric to correctly placed in res function handle to attain correct values for res
Thank you in advance
Respuestas (1)
SAI SRUJAN
el 31 de En. de 2024
Hi Oguz,
I understand that you are trying to solve a system of equations with 'bvp4c'.
To pass a vector input to a function handle in 'bvp4c', you can use an anonymous function to capture the vector and pass it to the function handle.
Please refer to the following code outline to proceed further :
U_numeric = [1 2 3 4];
res = @(y, res, U_numeric) [D_constant*(res(1)-res(2)); (U_numeric(y)-D_constant*(res(1)-res(2)))/C_constant; res(3); res(4)];
bc2 = @(T0, TH) [TH(3); TH(4); T0(1); T0(2)];
solinit = bvpinit(y_mesh, [1 0 1 0]);
sol2 = bvp4c(res, bc2, solinit);
In this example, I added an extra input 'U_numeric' to the 'res' function handle. Inside the 'res' function handle, 'U_numeric(y)' is used to access the corresponding value of 'U_numeric' at the given 'y' position.You can modify the code outline above to get the exact function handle.
For a comprehensive understanding of the 'bvp4c' function in MATLAB, please refer to the following documentation.
I hope this helps!
0 comentarios
Ver también
Categorías
Más información sobre Boundary Value Problems en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!