How can i fix the error 'Index exceeds the number of array elements (51)'
3 次查看(过去 30 天)
显示 更早的评论
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
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 个)
另请参阅
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!