Search All of the Math Forum:

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

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: compose matrix
Replies: 5   Last Post: Jul 27, 2013 3:48 AM

 Messages: [ Previous | Next ]
 Nasser Abbasi Posts: 6,677 Registered: 2/7/05
Re: compose matrix
Posted: Jul 20, 2013 8:33 PM

On 7/20/2013 6:18 PM, eziwarman wrote:

>>> hi guys,
>>> I am having a bit fuzzy to loop the matrix
>>>
>>> say you have the matrix (1x4)
>>> u=[0 -5 0 5 0]
>>> and construct the matrix into (4x10)
>>> y=[ 0 -5 0 5 0 0 0 0 0 0;...
>>> 0 0 0 -5 0 5 0 0 0 0;...
>>> 0 0 0 0 0 -5 0 5 0 0;...
>>> 0 0 0 0 0 0 0 -5 0 5];
>>>
>>> Thanks

> could you give me a sample
> i am a new learner with matlab
>

something like: (btw, the final matrix shuld be 4x11
not 4x10)

-------------------------
u=[0 -5 0 5 0];
M=4;
N=11;
A=zeros(M,N);
offset = 1;
for i=1:M
A(i,offset:offset+length(u)-1)=u;
offset = offset+2;
end
-----------------

A =
0 -5 0 5 0 0 0 0 0 0 0
0 0 0 -5 0 5 0 0 0 0 0
0 0 0 0 0 -5 0 5 0 0 0
0 0 0 0 0 0 0 -5 0 5 0

Date Subject Author
7/20/13 eziwarman
7/20/13 Nasser Abbasi
7/26/13 eziwarman
7/27/13 Roger Stafford