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

1 回表示 (過去 30 日間)
Neha Binish
Neha Binish 2020 年 4 月 6 日
コメント済み: Neha Binish 2020 年 4 月 8 日
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).

採用された回答

Birdman
Birdman 2020 年 4 月 6 日
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'

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDimensionality Reduction and Feature Extraction についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by