Index exceeds the number of array elements (1).
1 回表示 (過去 30 日間)
古いコメントを表示
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
0 件のコメント
採用された回答
Cris LaPierre
2023 年 3 月 31 日
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 件のコメント
Torsten
2023 年 4 月 17 日
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
2023 年 4 月 17 日
We have to assume the code you have shared is accurate. We have no way of knowing what it should be.
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!