# why is showing Inf and Nan value how to remove that

2 visualizaciones (últimos 30 días)
shiv gaur el 2 de Mzo. de 2022
Editada: Jan el 12 de Mzo. de 2022
a(1)=0;
b(1)=1;
c(1)=0;
k3=28;
k1=8/3;
k2=10;
s1=0;
s2=0;
s3=0;
T=0.1;
t=0:0.01:0.1;
tau = t ./ T;
for i=1:20
a(i+1)=(1/(i+1)).*(b(i)-a(i))*k2;
b(i+1)=(1/(i+1)).*(T*a(i).*(k3-c(i))-b(i));
c(i+1)=(1/(i+1))*(T*a(i).*b(i)-k1*c(i));
s1=s1+(a(i).*tau.^i);
s2=s2+(b(i).*tau.^i);
s3=s3+(c(i).*t.au^i);
disp([s1;s2;s3])
end
plot(t, s1, t, s2, t, s3)
disp is showing INF NAn
##### 6 comentariosMostrar 4 comentarios más antiguosOcultar 4 comentarios más antiguos
Mathieu NOE el 2 de Mzo. de 2022
hello again
simply testing the code for 10 iterations shows the diverging trend...
what was the expected result ?
Jan el 2 de Mzo. de 2022
Editada: Jan el 12 de Mzo. de 2022
@shiv gaur: You have been asked repeatedly to use a proper code formatting. Please read and consider this: https://www.mathworks.com/matlabcentral/answers/help/rtc#rtc_summary . Thanks.

Iniciar sesión para comentar.

### Respuestas (1)

Jan el 2 de Mzo. de 2022
Your function is growing exponentially. It is the mathematically correct behaviour, that it reaches Inf. "Fixing" this would mean, to compute something else, but this is not a meaningful solution.
##### 0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

### Categorías

Más información sobre Logical en Help Center y File Exchange.

R2021b

### Community Treasure Hunt

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

Start Hunting!

Translated by