How can this function as an excel add-in ?
조회 수: 1 (최근 30일)
이전 댓글 표시
Hello , I want to turn this code into a function , as I want to export it as a excel add-in ,with 3 entries , length, time, and concentration. The code is a pde equation with the pdepe solver , but does not work properly . What I have to change in the code to make it run? Thanks in advance for the help.
modelo_leaching(100,20,1)
function a=modelo_leaching(length,tiempo,conc)
x = 0:1:length; %length
t = 0:1:tiempo;%tiempo
m = 0;
sol = pdepe(m,@pdefun,@pdeic,@pdebc,x,t,conc);
u1 = sol(:,:,1);
surf(x,t,u1)
zlabel('Mineral conc(x,t)')
xlabel('Distance x')
ylabel('Time t')
function [c,f,s] = pdefun(length,t,u,dudx) % Equation to solve
U=10;
E=0.1e-8;
c = 1;
k=0.0017;
j=1.3703;
b=1.071;
cc=0.1195;
Ox=8;
cn=159;
f = E.* dudx;% - U.*u;
y =k*((u-0.17)^j)*((cn)^b)*((Ox)^cc) ;% ((u-0.17)^1); %(u-0.17)^0.3;
s = -y -U.*dudx ;
end
% ---------------------------------------------
function u0 = pdeic(length,conc) % Initial Conditions
u0 = conc; %Concentration
end
% ---------------------------------------------
function [pl,ql,pr,qr] = pdebc(xl,ul,xr,ur,tiempo,conc) % Boundary Conditions
Cai=conc;%Concentration
pl = ul-Cai;
ql = 0;
pr = 0;
qr = 1;
end
end
댓글 수: 0
채택된 답변
Walter Roberson
2023년 10월 23일
modelo_leaching(100,20,1)
function a=modelo_leaching(length,tiempo,conc)
x = 0:1:length; %length
t = 0:1:tiempo;%tiempo
m = 0;
sol = pdepe(m,@pdefun,@(X)pdeic(X,conc),@(xl,ul,xr,ur,tiempo)pdebc(xl,ul,xr,ur,tiempo,conc),x,t);
u1 = sol(:,:,1);
surf(x,t,u1)
zlabel('Mineral conc(x,t)')
xlabel('Distance x')
ylabel('Time t')
function [c,f,s] = pdefun(length,t,u,dudx) % Equation to solve
U=10;
E=0.1e-8;
c = 1;
k=0.0017;
j=1.3703;
b=1.071;
cc=0.1195;
Ox=8;
cn=159;
f = E.* dudx;% - U.*u;
y =k*((u-0.17)^j)*((cn)^b)*((Ox)^cc) ;% ((u-0.17)^1); %(u-0.17)^0.3;
s = -y -U.*dudx ;
end
% ---------------------------------------------
function u0 = pdeic(length,conc) % Initial Conditions
u0 = conc; %Concentration
end
% ---------------------------------------------
function [pl,ql,pr,qr] = pdebc(xl,ul,xr,ur,tiempo,conc) % Boundary Conditions
Cai=conc;%Concentration
pl = ul-Cai;
ql = 0;
pr = 0;
qr = 1;
end
end
댓글 수: 0
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!