Why do I keep getting the same error?
Afficher commentaires plus anciens
% Reporte escrito fenómenos
function Reporte
clc;clear;format compact
tauf=2;
N=10;
Bi=0.5;
thetaI(1:N-2)=1;
epsilon=linspace(0,1,N);
[tau,FUN]=ode15s(@ProbEDO,[0,tauf],thetaI)
plot(tau,FUN)
end
function ProbEDO(tau,T)
deltaepsilon=1/(N-1);
theta(1:N)=0;
theta(2:N-1)=T;
theta(1)=[4*theta(2)-theta(3)]/3;
theta(N)=(4*theta(N-1)-theta(N-2))/(3+2*Bi*deltaepsilon);
for i=2:N-1
FUN(i-1)=(theta(i+1)-2*theta(i)+theta(i-1))/(deltaepsilon^2)+(theta(i+1)-theta(i-1))/(2*epsilon(i)*deltaepsilon);
FUN=FUN.';
return
end
end
1 commentaire
Alvaro
le 2 Mai 2024
Réponses (1)
Walter Roberson
le 2 Mai 2024
function ProbEDO(tau,T)
deltaepsilon=1/(N-1);
theta(1:N)=0;
theta(2:N-1)=T;
theta(1)=[4*theta(2)-theta(3)]/3;
theta(N)=(4*theta(N-1)-theta(N-2))/(3+2*Bi*deltaepsilon);
for i=2:N-1
FUN(i-1)=(theta(i+1)-2*theta(i)+theta(i-1))/(deltaepsilon^2)+(theta(i+1)-theta(i-1))/(2*epsilon(i)*deltaepsilon);
FUN=FUN.';
return
end
end
You calculate an array FUN, but you do not return it to the caller.
Note also that your return will happen when i = 2. It is a waste of a for loop if you return within it.
Also, N is not defined within your function.
1 commentaire
Alvaro
le 2 Mai 2024
Catégories
En savoir plus sur Programming dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!