Syntax of res-function for bvp4c
Ältere Kommentare anzeigen
function res = bcfun(ya,yb,I)
ya(1)=850;
yb(1)=303;
ya(3)=850;
yb(3)=303;
ya(5)=r_cu; %constant
yb(5)=r_cu-((rho_p_T_c/A_p+rho_n_T_c/A_n)-(rho_p_T_h/A_p+rho_n_T_h/A_n))*L; %all constants
V_tho=2*I*(r_cu+(rho_p_T_c/A_p+rho_n_T_c/A_n)*L)-(alpha_p_T_h-alpha_n_T_h)*T_h-(alpha_p_T_c-alpha_n_T_c)*T_c; %all constants except for parameter I
res = [ya(1)-yb(1)
ya(3)-yb(1)
ya(2)
ya(4)
ya(5)
yb(5)
ya(6)
yb(6)-V_tho];
end
25 Kommentare
Torsten
am 13 Nov. 2018
If you want to set yi at x=0 to a value "v", res = ya(i) - v.
If you want to set yi at x=L to a value "v", res = yb(i) - v.
Justin Riggio
am 13 Nov. 2018
Justin Riggio
am 13 Nov. 2018
Torsten
am 13 Nov. 2018
So y(2) at x=0 is a function of y(1) at x=1 and y(4) at x=0 is a function of y(3) at x=1 ? This is only possible if an explicit value for y(2) at x=0 or y(1) at x=1 is prescribed as a second boundary condition for the first case and if an explicit value for y(4) at x=0 or y(3) at x=1 is prescribed as a second boundary condition for the second case.
Justin Riggio
am 13 Nov. 2018
Bearbeitet: Justin Riggio
am 13 Nov. 2018
Torsten
am 13 Nov. 2018
If x=1 is the right boundary point, you can set
res = ya(2)-k_p_t_h*A_p*(T_h-yb(1))
But ya(2) or yb(1) must be specified somewhere else as explicit boundary condition, e.g.
res = ya(2) - 20
If x=1 is not a boundary point, the condition cannot be set in bvp4c.
Justin Riggio
am 13 Nov. 2018
Justin Riggio
am 14 Nov. 2018
Bearbeitet: madhan ravi
am 15 Nov. 2018
Torsten
am 14 Nov. 2018
Call bvp4c like
sol = bvp4c(@odefun,@(ya,yb)bcfun(ya,yb,solinit),solinit);
to make "solinit" available in "bcfun".
Justin Riggio
am 14 Nov. 2018
Torsten
am 14 Nov. 2018
Did you also change the argument list of the bcfun-routine itself:
function res = bcfun(ya,yb,solinit)
?
Justin Riggio
am 14 Nov. 2018
Torsten
am 15 Nov. 2018
Then
sol = bvp4c(@odefun,@(ya,yb,l)bcfun(ya,yb,l,solinit),solinit);
Justin Riggio
am 15 Nov. 2018
Torsten
am 15 Nov. 2018
Try if it works if you use the line
global solinit
in the program where you call bvp4c as well as in bcfun.
Justin Riggio
am 15 Nov. 2018
I think the error before arises because you did not initialize your parameter l within the solinit construct.
Take a look at the example
"Compute Fourth Eigenvalue of Mathieu’s Equation"
under
especially the definition of "solinit".
Justin Riggio
am 15 Nov. 2018
Justin Riggio
am 15 Nov. 2018
Justin Riggio
am 15 Nov. 2018
madhan ravi
am 15 Nov. 2018
@Justin i edited all your comment next time format it properly so that it's easy to read
Justin Riggio
am 15 Nov. 2018
Justin Riggio
am 15 Nov. 2018
Justin Riggio
am 15 Nov. 2018
Antworten (0)
Kategorien
Mehr zu Mathematics finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!