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 views (last 30 days)
Show older comments
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
0 Comments
Accepted Answer
Torsten
on 16 Nov 2023
Edited: Torsten
on 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);
More Answers (0)
See Also
Categories
Find more on Vector Fields 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!