Index exceeds the number of array elements (1).

3 vues (au cours des 30 derniers jours)
MALLIKARJUNA M
MALLIKARJUNA M le 31 Mar 2023
Commenté : Cris LaPierre le 17 Avr 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

Réponse acceptée

Cris LaPierre
Cris LaPierre le 31 Mar 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 commentaires
Torsten
Torsten le 17 Avr 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 le 17 Avr 2023
We have to assume the code you have shared is accurate. We have no way of knowing what it should be.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Mathematics dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by