Index exceeds the number of array elements (1).

4 visualizaciones (últimos 30 días)
MALLIKARJUNA M
MALLIKARJUNA M el 31 de Mzo. de 2023
Comentada: Cris LaPierre el 17 de Abr. de 2023
I am trying to generate a graph for the analytical expression I got and I used for loop since my solution is in summation but i am getting the error
Index exceeds the number of array elements (1).
here is the expression, please help me to rectify the error
for n=0:1:N
d=a.*pi.*(-1).^n.*(2.*n + 1).*sin(sqrt(m./r).*(x - 1)).*exp(-(a + pi.^2.*(2.*n + 1).^2./4).*t)./(m.*(a.*r - m.*(r - 1)).*sin(sqrt(m./r))) - 2.*a.*(((-1).^n.*sin(n.*pi.*(x - 1))./(n(a.*r - n.^2.*pi.^2.*r.*(r - 1)).*cosh(sqrt(-n.^2.*pi.^2.*r + a))) - sin(n.*pi.*x)).*exp(-n.^2.*pi.^2.*r.*t) + (r - 1).*(2.*sin(sqrt(a./(r - 1)).*(x - 1))./sin(2.*sqrt(a./(r - 1))) - sin(sqrt(a./(r - 1)).*x)./sin(sqrt(a./(r - 1))) + cos(sqrt(a./(r - 1)).*x)./cos(sqrt(a./(r - 1)))).*exp(-a.*r.*t./(r - 1))./r)./pi;
end

Respuesta aceptada

Cris LaPierre
Cris LaPierre el 31 de Mzo. de 2023
I suspect the error is that you forgot to include a multiply in this statement after n
(n(a.*r - n.^2.*pi.^2.*r.*(r - 1))
% Should probably be
(n*(a.*r - n.^2.*pi.^2.*r.*(r - 1))
% ^
  3 comentarios
Torsten
Torsten el 17 de Abr. de 2023
I'm getting NaN values when setting x = t = 1 (see above).
What are x and t in your case ?
Note that a=mu./1+k; is most probably wrong. I guess you wanted to set a=mu./(1+k);
I didn't look through the formula for d for similar errors.
Cris LaPierre
Cris LaPierre el 17 de Abr. de 2023
We have to assume the code you have shared is accurate. We have no way of knowing what it should be.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

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

Community Treasure Hunt

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

Start Hunting!

Translated by