필터 지우기
필터 지우기

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,

조회 수: 2 (최근 30일)
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

채택된 답변

Torsten
Torsten 2023년 11월 16일
편집: Torsten 2023년 11월 16일
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
Sanley Guerrier
Sanley Guerrier 2023년 11월 16일
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 2023년 11월 16일
편집: Torsten 2023년 11월 16일
Maybe
can help.
Note that your "time" vector should include the time interval "t" you use for the integration.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 PDE Solvers에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by