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: double for loop
Replies: 5   Last Post: Sep 9, 2013 10:29 AM

Advanced Search

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

Posts: 17,944
Registered: 12/7/04
Re: double for loop
Posted: Sep 9, 2013 10:29 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply



"cwc " <Darrylcwc@live.com.sg> wrote in message
news:l0kbli$em6$1@newscl01ah.mathworks.com...
> I don't understand the process as to how
> [1,2;3,4;5,6]
>
> gets to
> [ 1 1 2 2
> 1 1 2 2
> 3 3 4 4
> 3 3 4 4 5 5 6 6
> 5 5 6 6 ]
>
> if ii and jj represents the length of the original matrix then why would
> it double?


Please post the EXACT code you run that generates this new larger matrix.
The original code you posted:

> [x,y] = size(z)
>
> for ii = 1:x;
> for jj = 1:y;
>
> newz = z(ii,jj)
>
> end


does NOT do this (assuming we add the extra end to close the first FOR
loop.)

If on the other hand you WANT to obtain that larger matrix, use the KRON
function.

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




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.