Thread Subject:
Create large matrix from elements of smaller matrix

Subject: Create large matrix from elements of smaller matrix

From: Tom Sutherland

Date: 10 Aug, 2012 13:38:13

Message: 1 of 3

I want to take each element of a MxN matrix and add it to a group(TxV) of elements of another matrix that is MxTxNxV. So a single element of MN gets added to a group of elements of the MTNV matrix.
Is there a faster method to do this besides doing 'for' loops?
Example:
% Long Version
for n=1:N
 for m=1:M
    for t=1:T-1
      for v=1:V-1
       TV(n*t+t-1, m*v+v-1) = MN(n,m) + TV(n*t+t-1, m*v+v-1);
      end
    end
 end
end


Thanks...Tom

Subject: Create large matrix from elements of smaller matrix

From: Matt J

Date: 10 Aug, 2012 15:33:13

Message: 2 of 3

"Tom Sutherland" wrote in message <k032s5$11j$1@newscl01ah.mathworks.com>...
> I want to take each element of a MxN matrix and add it to a group(TxV) of elements of another matrix that is MxTxNxV. So a single element of MN gets added to a group of elements of the MTNV matrix.
> Is there a faster method to do this besides doing 'for' loops?
> Example:
> % Long Version
> for n=1:N
> for m=1:M
> for t=1:T-1
> for v=1:V-1
> TV(n*t+t-1, m*v+v-1) = MN(n,m) + TV(n*t+t-1, m*v+v-1);
=================


Is this what you want:

TV=TV+kron(MN, ones(T,V));

Subject: Create large matrix from elements of smaller matrix

From: Tom Sutherland

Date: 10 Aug, 2012 17:24:10

Message: 3 of 3

"Matt J" wrote in message <k039jp$psu$1@newscl01ah.mathworks.com>...
> "Tom Sutherland" wrote in message <k032s5$11j$1@newscl01ah.mathworks.com>...
> > I want to take each element of a MxN matrix and add it to a group(TxV) of elements of another matrix that is MxTxNxV. So a single element of MN gets added to a group of elements of the MTNV matrix.
> > Is there a faster method to do this besides doing 'for' loops?
> > Example:
> > % Long Version
> > for n=1:N
> > for m=1:M
> > for t=1:T-1
> > for v=1:V-1
> > TV(n*t+t-1, m*v+v-1) = MN(n,m) + TV(n*t+t-1, m*v+v-1);
> =================
>
>
> Is this what you want:
>
> TV=TV+kron(MN, ones(T,V));

Yes, That looks like it does close to what I want. Thanks!!!

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

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.

Tag Activity for This Thread
Tag Applied By Date/Time
matrix Tom Sutherland 10 Aug, 2012 09:39:17
repmat Tom Sutherland 10 Aug, 2012 09:39:17
matrices Tom Sutherland 10 Aug, 2012 09:39:17
summation Tom Sutherland 10 Aug, 2012 09:39:17
remapping Tom Sutherland 10 Aug, 2012 09:39:17
rssFeed for this Thread

Contact us