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 Center および File ExchangeProgramming についてさらに検索

製品


リリース

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by