Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: 3 noob questions about cells
Replies: 3   Last Post: Jan 9, 2013 12:59 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
kj

Posts: 184
Registered: 8/17/09
3 noob questions about cells
Posted: Jan 8, 2013 3:48 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply



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!




Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.