Index exceeds the number of array elements (11)
1 回表示 (過去 30 日間)
古いコメントを表示
Hi, how could i take it off the error?
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/300813/image.png)
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!