Index exceeds the number of array elements (11)
1 次查看(过去 30 天)
显示 更早的评论
Hi, how could i take it off the error?
1 个评论
Ruben Lange
2020-5-25
Hello,
It seems that you tried to use entry 11 of your vector x. In line 4 however, you stated that x would be a vector of length 10 with values ranging from 0 to 1. In your for loop you let i cycle from 1 to 20, so as soon as i reaches 11, it can't find a value in x as x only reaches to 10 entries.
Hope that helps.
回答(1 个)
Michel Lopes Villaluz
2020-5-25
1 个评论
Walter Roberson
2020-5-25
编辑:Walter Roberson
2020-5-25
You need explicit multiplication between the 2 and the x.
Also as we discuss in your other posting, you need to use exp()
fplot('-exp(-x)+x.^2-2*x+2',[0 1])
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!