Why do I keep getting the same error?

조회 수: 6 (최근 30일)
Alvaro
Alvaro 2024년 5월 2일
댓글: Alvaro 2024년 5월 2일
% 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
Alvaro
Alvaro 2024년 5월 2일
Error using Reporte>ProbEDO
Too many output arguments.
Error in odearguments (line 92)
f0 = ode(t0,y0,args{:}); % ODE15I sets args{1} to yp0.
Error in ode15s (line 148)
odearguments(odeIsFuncHandle, odeTreatAsMFile, solver_name, ode, tspan, y0, options, varargin);
Error in Reporte (line 10)
[tau,FUN]=ode15s(@ProbEDO,[0,tauf],thetaI)

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

답변 (1개)

Walter Roberson
Walter Roberson 2024년 5월 2일
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
Alvaro
Alvaro 2024년 5월 2일
I keep getting the same error, any idea on how can I fix it?

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

카테고리

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

제품


릴리스

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by