Why do I keep getting the same error?

7 次查看(过去 30 天)
% 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.

类别

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