# Why do I keep getting the same error?

2 Ansichten (letzte 30 Tage)
Alvaro am 2 Mai 2024
Kommentiert: Alvaro am 2 Mai 2024
% 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 Kommentar-1 ältere Kommentare anzeigen-1 ältere Kommentare ausblenden
Alvaro am 2 Mai 2024
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)

Melden Sie sich an, um zu kommentieren.

### Antworten (1)

Walter Roberson am 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 Kommentar-1 ältere Kommentare anzeigen-1 ältere Kommentare ausblenden
Alvaro am 2 Mai 2024
I keep getting the same error, any idea on how can I fix it?

Melden Sie sich an, um zu kommentieren.

R2023b

### Community Treasure Hunt

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

Start Hunting!

Translated by