Adressing a cell
显示 更早的评论
I ran into an issue today and got it sorted out, but I want to understand what the reasoning behind it is.
I have a 1x10 cell named Rx{n},n=1:10. For simplicity's sake, lets just say the cells are filled sequentially 1-10.
Rx(5)=5
Also:
Rx{1,5}=5
I ran into an issue when I was trying to use the values in a legend.
legend(Rx(1),Rx(2)...) -Does not work
legend(Rx{1,1},Rx{1,2}...) -Does work
Since it is not a cell array, and each cell just contains 1 value, why aren't these equivalent?
采纳的回答
更多回答(1 个)
the cyclist
2011-10-20
0 个投票
In the case that works, you are using curly brackets, which means you are referring to the contents of the cell, which is presumably an appropriate input to the legend() function.
In the case that does not work, you are using parenthesis, which means you are referring to the cell itself (not the contents of the cell), and that is not a valid input to the legend() function.
类别
在 帮助中心 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!