Indexing problem based on value?
显示 更早的评论
Hi,
I encountered a strange problem. For A= [5 4 3 2 1 0 1 2 3 4 5];
I can't do B = A(1): A(6). The return is 1×0 empty double row vector. if I do A(7): A(8) or start from index 7, I can get the output.
I am not sure what is the source of problem. I expected A(1) : A(6) = [5 4 3 2 1 0].
I tried A(1:6) and it works. what is the difference between A(1:6) and A(1): A(6) while the latter doesn't work?
Thanks.
采纳的回答
更多回答(1 个)
SHIVANI CHORGE
2020-5-22
编辑:SHIVANI CHORGE
2020-5-22
A(1) : A(6)=A(1:6)
A= [5 4 3 2 1 0 1 2 3 4 5]
this is in vector form hence A(1) : A(6) this is not working
if you expected like this A(1) : A(6) = [5 4 3 2 1 0]
than use it
A(1) : A(6)=A(1:6)
类别
在 帮助中心 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!