I am creating a vector but its throwing some error. Example I create vector a= [3.4 -4.90 0.23], and when I access it a[1] it gives error.
1 次查看(过去 30 天)
显示 更早的评论
array problem
采纳的回答
Shivani Dixit
2021-6-7
In MATLAB, we access the elements of an array using paranthesis () and not square brackets [ ]. You can see an example below :
arr =[3.4 -4.90 0.23];
arr(1)=3.4 % using arr[1] would lead to error as in your case
arr(2)=-4.90
arr(3)=0.23
2 个评论
更多回答(1 个)
KSSV
2021-6-7
You should not use square braces.. a[1] not allowed.
Use a(1)
a= [3.4 -4.90 0.23] ;
a(1)
a(end)
0 个评论
另请参阅
类别
在 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!