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

# 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 ... > 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 ... > "Tom Sutherland" wrote in message ... > > 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!!!