Not enough input arguments. Error in mypde_model>bcfun (line 53) ptop =utop - interp1(time, mydata(:,5), t,'spline'); Error in mypde_model (line 17) sol = pdepe(m, @pdefun,

3 vues (au cours des 30 derniers jours)
Dear expert;
Could you help me figure out why the bcfun function is not working and help fix the problem?
Thank you!
clear
close all
clc
load mydata.mat
time = datetime(mydata.DAY) + (mydata.HOUR + mydata.QHR/4)/24; % matrix (35040 X 1)
Z=17; % depth in inches
z = linspace(0,Z,200); % length vector
t = linspace(0, 100,35040);% time vector
m= 0;
u_ini1= -4.705; %Temperature [deg C]
u_ini2= -0.594; % Temperature [deg C]
% solve pdepe-------------------------------------------------
sol = pdepe(m, @pdefun, @icfun, bcfun, z, t);
T = sol(:,:,1);
%Temperature profile at final time t
figure (1)
plot(t, T(end,:))
xlabel('Time')
ylabel('Temperature [deg C]')
% Build function for PDEs -------------------------------
function [c,f,s] = pdefun(z,t, u, dudz)
K =1.2; % conductivity(W/m-K)
rho=2200; % density(kg/m^3)
Cp=921; % specific heat capacity(J/kg-K)
c=rho*Cp/K;
f = dudz;
s = 0;
end
% build function for initial conditions------------------------
function u0 = icfun(z, T_ini1,T_ini2, Z)
u_ini1= -4.705;
u_ini2= -0.594;
u0 = T_ini1 + z/Z*(T_ini2-T_ini1);
end
% build function for boundary conditions-----------------------
function [ptop,qtop, pbot,qbot] = bcfun(ztop, utop, zbot, ubot,t,time, mydata)
ptop =utop - interp1(time, mydata(:,5), t,'spline'); %?????.......
qtop= 0;
pbot = -ubot + interp1(time, mydata(:,end), t, 'spline');%????......
qbot= 1;
end

Réponse acceptée

Torsten
Torsten le 16 Nov 2023
Modifié(e) : Torsten le 16 Nov 2023
Use
sol = pdepe(m, @pdefun, @(z)icfun(z,u_ini1,u_ini2, Z),@(ztop, utop, zbot, ubot,t) bcfun(ztop, utop, zbot, ubot,t,time, mydata), z, t);
instead of
sol = pdepe(m, @pdefun, @icfun, bcfun, z, t);
  6 commentaires
Sanley Guerrier
Sanley Guerrier le 16 Nov 2023
Thank you for helping.
I am going to mess a little bit with the array "time". Right now it is a "datetime" array.
Torsten
Torsten le 16 Nov 2023
Modifié(e) : Torsten le 16 Nov 2023
Maybe
can help.
Note that your "time" vector should include the time interval "t" you use for the integration.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by