Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Cell Syntax Quiz

Subject: Cell Syntax Quiz

From: Greg Heath

Date: 11 Jan, 2013 08:28:07

Message: 1 of 7

% CELL SYNTAX QUIZ

close all, clc

% For each expression
% 1. Write the command line response
% 2. Cut and paste the expression into the command line
% 3. Award yourself 6 points for each correct answer
% 4. Add 5 extra points if the expression is one of the last 2

A{1,1} = [1 2 ]
A{2,2} = [ 5 6 ]
A{2,1} = 4
A{1,2} = 3
A{ : }
A{ : , : }
A{ : , : , : }
isequal( A{ : } , A{ : , : } )

B0 = A
isequal(A,B0)
B1 = A{:}
B2 = A{:, :}
isequal( B1 , B2 )

whos
cell2mat(B0)

% Any comments?

Subject: Cell Syntax Quiz

From: dpb

Date: 11 Jan, 2013 14:36:55

Message: 2 of 7

On 1/11/2013 2:28 AM, Greg Heath wrote:
> % CELL SYNTAX QUIZ
>
> close all, clc
>
> % For each expression
> % 1. Write the command line response
> % 2. Cut and paste the expression into the command line
> % 3. Award yourself 6 points for each correct answer
> % 4. Add 5 extra points if the expression is one of the last 2
>
> A{1,1} = [1 2 ]
> A{2,2} = [ 5 6 ]
> A{2,1} = 4 A{1,2} = 3
> A{ : }
> A{ : , : }
> A{ : , : , : }
> isequal( A{ : } , A{ : , : } )
>
> B0 = A
> isequal(A,B0)
> B1 = A{:} B2 = A{:, :}
> isequal( B1 , B2 )
>
> whos
> cell2mat(B0)
>
> % Any comments?

Yeah, my old eyes can't easily tell {} from () so it's a crapshoot to
try... :)

--

Subject: Cell Syntax Quiz

From: Steven_Lord

Date: 11 Jan, 2013 15:26:49

Message: 3 of 7



"dpb" <none@non.net> wrote in message news:kcp81t$a5o$1@speranza.aioe.org...

*snip*

> Yeah, my old eyes can't easily tell {} from () so it's a crapshoot to
> try... :)

FYI if you're on Windows, this may help:

http://en.wikipedia.org/wiki/Magnifier_%28Windows%29

That gives you a virtual magnifying glass that may make parentheses and
curly braces easier to distinguish.

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Subject: Cell Syntax Quiz

From: Bruno Luong

Date: 11 Jan, 2013 20:26:07

Message: 4 of 7

I'll try to answer the quiz without MATLAB:

> % CELL SYNTAX QUIZ
>
> close all, clc
>
> % For each expression
> % 1. Write the command line response
> % 2. Cut and paste the expression into the command line
> % 3. Award yourself 6 points for each correct answer
> % 4. Add 5 extra points if the expression is one of the last 2
>
> A{1,1} = [1 2 ]
> A{2,2} = [ 5 6 ]
> A{2,1} = 4
> A{1,2} = 3
> A{ : }
> A{ : , : }
> A{ : , : , : }

> isequal( A{ : } , A{ : , : } )

return false

>
> B0 = A
> isequal(A,B0)

return true

> B1 = A{:}
> B2 = A{:, :}
> isequal( B1 , B2 )

return true

>
> whos
> cell2mat(B0)

return an error

% Bruno

Subject: Cell Syntax Quiz

From: dpb

Date: 11 Jan, 2013 20:47:25

Message: 5 of 7

On 1/11/2013 9:26 AM, Steven_Lord wrote:
> "dpb" <none@non.net> wrote in message
> news:kcp81t$a5o$1@speranza.aioe.org...
>
> *snip*
>
>> Yeah, my old eyes can't easily tell {} from () ...
>
> FYI if you're on Windows, this may help:
>
> http://en.wikipedia.org/wiki/Magnifier_%28Windows%29
>
> That gives you a virtual magnifying glass that may make parentheses and
> curly braces easier to distinguish.

I'd forgotten about it, Steven, thanks. While I can read text, etc.,
well, the particular two of the curlies and parens are almost
indistinquishable w/o enlarging the font larger than I care for it to be
routinely.

When I'm typing it's not so bad; I generally know what I want--it's
trying to read somebody else's code and/or postings that's a
pit[proverbialappendage]

--

Subject: Cell Syntax Quiz

From: dpb

Date: 11 Jan, 2013 20:55:48

Message: 6 of 7

On 1/11/2013 2:28 AM, Greg Heath wrote:
On 1/11/2013 2:28 AM, Greg Heath wrote:
> % CELL SYNTAX QUIZ
>
...

> isequal( A{ : } , A{ : , : } )
>
...

OK, I see after looking more that it isn't as I suspected initially a
test between curlies and parens so much but more on dereferencing...

isequal( [A{ : }] , [A{ : , : }] )

I'm not sure how the parser deals w/ the comma-separated list in an
argument, precisely because again it's not documented thoroughly beyond
just the description (wonder whether ever heard that from me before? :)
).

The actual content is the same as the [] shows altho clearly the
representation seen by the parser passed to the function has something
invisible that distinguishes the two. What, precisely, that is, I don't
know. Steve?

--

Subject: Cell Syntax Quiz

From: Greg Heath

Date: 12 Jan, 2013 01:28:09

Message: 7 of 7

dpb <none@non.net> wrote in message <kcp81t$a5o$1@speranza.aioe.org>...
> On 1/11/2013 2:28 AM, Greg Heath wrote:
> > % CELL SYNTAX QUIZ
> >
> > close all, clc
> >
> > % For each expression
> > % 1. Write the command line response
> > % 2. Cut and paste the expression into the command line
> > % 3. Award yourself 6 points for each correct answer
> > % 4. Add 5 extra points if the expression is one of the last 2
> >
> > A{1,1} = [1 2 ]
> > A{2,2} = [ 5 6 ]
> > A{2,1} = 4 A{1,2} = 3
> > A{ : }
> > A{ : , : }
> > A{ : , : , : }
> > isequal( A{ : } , A{ : , : } )
> >
> > B0 = A
> > isequal(A,B0)
> > B1 = A{:} B2 = A{:, :}
> > isequal( B1 , B2 )
> >
> > whos
> > cell2mat(B0)
> >
> > % Any comments?
>
> Yeah, my old eyes can't easily tell {} from () so it's a crapshoot to
> try... :)

Join the club!!

I have Windoze 7 and rely heavily on control +

However, it does not work in the MATLAB environment.

Greg

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us