MATLAB Answers

How can i fix the error 'Index exceeds the number of array elements (51)'

조회 수: 14(최근 30일)
Neha Binish
Neha Binish 6 Apr 2020
댓글: Neha Binish 8 Apr 2020
x = [0:0.1:5];
y = sin(x)/x;
plot(x, y), xlabel('xi'), ylabel('Theta'), title('Solution to Lane Emden Equation'),
grid on, axis equal;ax = gca; ylabel = texlabel(y); xlabel = texlabel(x);
ax.XAxisLocation = 'origin'
ax.YAxisLocation = 'origin'
Index exceeds the number of array elements (51).

  댓글 수: 0

댓글을 달려면 로그인하십시오.

채택된 답변

Birdman
Birdman 6 Apr 2020
You need to apply elementwise division:
x = [0:0.1:5];
y = sin(x)./x;
plot(x, y), xlabel('xi'), ylabel('Theta'), title('Solution to Lane Emden Equation'),
grid on, axis equal;ax = gca; ylabel = texlabel(y); xlabel = texlabel(x);
ax.XAxisLocation = 'origin'
ax.YAxisLocation = 'origin'

  댓글 수: 1

Neha Binish
Neha Binish 8 Apr 2020
Yes, that works. Thank you very much

댓글을 달려면 로그인하십시오.

추가 답변(0개)

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by