How can this function as an excel add-in ?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Raúl Rivera
le 23 Oct 2023
Réponse apportée : Walter Roberson
le 23 Oct 2023
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 commentaires
Réponse acceptée
Walter Roberson
le 23 Oct 2023
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 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Introduction to Installation and Licensing dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!