Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
Drexel University or The Math Forum.


kj
Posts:
197
Registered:
8/17/09


3 noob questions about cells
Posted:
Jan 8, 2013 3:48 PM


1. How can I generate the cell equivalent to the literal
{1 2 3 ... 1000}
...(where the ellipses stand for the integers from 4 to 999) without actually writing out the 1,000 integers?
I had hoped that {1:1000} would do it, but no. As far as I can tell, {1 2 3} and {1:3} are not equivalent:
>> {1 2 3}
ans =
[1] [2] [3]
>> {1:3}
ans =
[1x3 double]
2. How can I generate the cell equivalent to the literal
{'A' 'B' ... 'Z'}
...(where the ellipses stand for the upper case letters from 'C' to 'Y') from the array ['A':'Z']?
I had hoped that {'A':'Z'} would do it, but no. As far as I can tell, {'A' 'B' 'C'} and {'A':'C'} are not equivalent:
>> {'A' 'B' 'C'}
ans =
'A' 'B' 'C'
>> {'A':'C'}
ans =
'ABC'
3. What is the (left) inverse of cell2mat? (I.e., what is the function foo such that foo(cell2mat(X)) and X are the same?)
I had hoped that it would be mat2cell, but no. As far as I can tell mat2cell(cell2mat({1 2 3})) is not equivalent to {1 2 3}:
>> {1 2 3}
ans =
[1] [2] [3]
>> mat2cell(cell2mat({1 2 3})) Warning: Single input behavior is obsolete and will be removed in a future release of MATLAB. Use C={X} instead. > In mat2cell at 54
ans =
[1x3 double]
>> {cell2mat({1 2 3})}
ans =
[1x3 double]
Thanks in advance!



