Adressing a cell
Show older comments
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?
Accepted Answer
More Answers (1)
the cyclist
on 20 Oct 2011
0 votes
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.
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!