I don't know what's wrong with the function.
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
It is a function consisting of t, Q, and C. I was trying to express this in MATLAB. But a problem arose in expressing Q. But I don't know why it's a problem. The red part seems to be wrong, but I can't fix it.
function dCdt = name(t,C,dz,u_column,D,F,H)
dCdt = zeros(column_Number*(Nz+1),1);
dQdt = name2(t,Q,C,H,Nz,column_Number)
C(1)=0.2;
for k = 1 : 4
for i = 1 : 100
dCdz(i) = 1./(dz).*(C(i)-C(i-1));
d2Cdz2(i) = 1./(dz^2.).*(C(i)-2.*C(i-1)+C(i-2));
% dQdt(i) = H*dCdt(i);
dCdt(i) = D.*d2Cdz2(i) - u_column*dCdz(i) + F*dQdt(i);
end % for i = 1 : 100
end % for k = 1 : 4
end % function
function dQdt = name2(t,Q,C,H)
for k = 1 : 4
for i = 1 : 100
Q(i) = H*C(i);
dQdt(i) = H*dCdt(i);
end % for i = 1 : 100
end % for k = 1 : 4
end % function
2 comentarios
Walter Roberson
el 14 de Feb. de 2022
for k = 1 : 4
for i = 1 : 100
Q(i) = H*C(i);
dQdt(i) = H*dCdt(i);
end % for i = 1 : 100
end % for k = 1 : 4
The assignments index at i but k is not used inside the nested loop. The exact same thing is going to be done every iteration of the for k loop -- the output is going to be exactly the same as if you did not have any for k loop.
Respuestas (0)
Ver también
Categorías
Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!