Thread Subject: Merging Matrices at subscript level

Subject: Merging Matrices at subscript level

From: Bc

Date: 9 Feb, 2010 17:45:05

Message: 1 of 5

Supposed I have A = [1 2 3; 4 5 6; 7 8 9] and B = [10 11 12; 13 14 15; 16 17 18]

and I want to get C = [1 10 2 11 3 12; 4 13 5 14 6 15; 7 16 8 17 9 18];

How would I be able to do this? I thought something like this, but it is not working for me because I am not doing it in all places on the matrix. I was wondering is there is a function for this.

% mat 1 and mat2 are both 288x288 so output4 is 576x576
% zp = 288;
% output4 = zeros(3*zp,3*zp);
% output4(1:3:end,1:3:end) = mat1;
% output4(2:2:end,2:2:end) = mat2;

Subject: Merging Matrices at subscript level

From: Oleg Komarov

Date: 9 Feb, 2010 18:03:04

Message: 2 of 5

"Bc "
> Supposed I have A = [1 2 3; 4 5 6; 7 8 9] and B = [10 11 12; 13 14 15; 16 17 18]
>
> and I want to get C = [1 10 2 11 3 12; 4 13 5 14 6 15; 7 16 8 17 9 18];
>
> How would I be able to do this? I thought something like this, but it is not working for me because I am not doing it in all places on the matrix. I was wondering is there is a function for this.
>
> % mat 1 and mat2 are both 288x288 so output4 is 576x576
> % zp = 288;
> % output4 = zeros(3*zp,3*zp);
> % output4(1:3:end,1:3:end) = mat1;
> % output4(2:2:end,2:2:end) = mat2;

% According to your example (A,B,C) which is inconsistent with your next request (Output4):
C = zeros(size(A,1),size(A,2)*2);
C(:,1:2:end) = A;
C(:,2:2:end) = B;

Oleg

Subject: Merging Matrices at subscript level

From: Bc

Date: 9 Feb, 2010 19:49:03

Message: 3 of 5

"Oleg Komarov" <oleg.komarovRemove.this@hotmail.it> wrote in message <hks80o$pht$1@fred.mathworks.com>...
> "Bc "
> > Supposed I have A = [1 2 3; 4 5 6; 7 8 9] and B = [10 11 12; 13 14 15; 16 17 18]
> >
> > and I want to get C = [1 10 2 11 3 12; 4 13 5 14 6 15; 7 16 8 17 9 18];
> >
> > How would I be able to do this? I thought something like this, but it is not working for me because I am not doing it in all places on the matrix. I was wondering is there is a function for this.
> >
> > % mat 1 and mat2 are both 288x288 so output4 is 576x576
> > % zp = 288;
> > % output4 = zeros(3*zp,3*zp);
> > % output4(1:3:end,1:3:end) = mat1;
> > % output4(2:2:end,2:2:end) = mat2;
>
> % According to your example (A,B,C) which is inconsistent with your next request (Output4):
> C = zeros(size(A,1),size(A,2)*2);
> C(:,1:2:end) = A;
> C(:,2:2:end) = B;
>
> Oleg
==========================================
Thank you for the help, so the results meets my initial inquiry.

Subject: Merging Matrices at subscript level

From: Jos (10584)

Date: 9 Feb, 2010 21:34:05

Message: 4 of 5

"Bc " <bcortez23@gmail.com> wrote in message <hks6v1$i1e$1@fred.mathworks.com>...
> Supposed I have A = [1 2 3; 4 5 6; 7 8 9] and B = [10 11 12; 13 14 15; 16 17 18]
>
> and I want to get C = [1 10 2 11 3 12; 4 13 5 14 6 15; 7 16 8 17 9 18];
>
> How would I be able to do this? I thought something like this, but it is not working for me because I am not doing it in all places on the matrix. I was wondering is there is a function for this.
>
> % mat 1 and mat2 are both 288x288 so output4 is 576x576
> % zp = 288;
> % output4 = zeros(3*zp,3*zp);
> % output4(1:3:end,1:3:end) = mat1;
> % output4(2:2:end,2:2:end) = mat2;

% data
  A = [1 2 3; 4 5 6; 7 8 9]
  B = [10 11 12; 13 14 15; 16 17 18]
% engine
  C = reshape([A ; B],3,[])

hth
Jos

Subject: Merging Matrices at subscript level

From: Bc

Date: 10 Feb, 2010 17:21:05

Message: 5 of 5

Ok, so I was talking to the TA yesterday and he said that the purpose is of the exercise is to put the problem into Ax = b form. Therefore, since I have the following:

for m=2:imR-1
    for n=2:imC-1
        for i=1:kRows
            for j=1:kCols
                I'(m,n) = I(m+i-2,n+j-2)*H(i,j);
            end
        end
    end
end

But, as you can see, I do not what to solve for x, or in my case H, but instead I want to solve for A, which is my I'. Any suggestions? (I = I'*B is actually a convolution, hence the loops)

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
merging matrices Bc 9 Feb, 2010 12:49:10
rssFeed for this Thread

Contact us at files@mathworks.com