Asked by Elysi Cochin
on 3 Dec 2013

i have a matrix with dimension

A = M * 361

i wanted to create a matrix with size

B = M * 3600

with this matrix A

how to do it??

also a matrix with dimension

C = N * 900

i wanted to create a matrix with size

D = N * 3600

how to do it?? please do reply...

with this matrix A

*No products are associated with this question.*

Answer by J Smith
on 3 Dec 2013

Edited by J Smith
on 3 Dec 2013

Accepted Answer

C and D have same number of rows. Similarly A and B have same number of rows. So C to D is straightforward since number of rows in C and D are equal, and D has 4 times the columns in C.

D=repmat(C,1,4)

and for A to B you can use this workaround.

B=repmat(A,1,10) B=B(:,1:3600);

I hope someone gives a straighter solution.

Answer by Andrei Bobrov
on 3 Dec 2013

Edited by Andrei Bobrov
on 3 Dec 2013

One way:

newsize2 = 3600; [i0,j0] = ndgrid(1:size(A,1),1:size(A,2)); F = griddedInterpolant(i0,j0); [io,jo] = ndgrid(i0(:,1),linspace(1,j0(end),newsize2)); B = F(io,jo);

or

B = zeros(M,3600); B = A(:,rem((1:size(B,2))-1,size(A,2))+1);

Log in to comment.

Related Content

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

Learn moreOpportunities for recent engineering grads.

Apply Today
## 4 Comments

## J Smith (view profile)

Direct link to this comment:https://www.mathworks.com/matlabcentral/answers/108390-create-a-matrix-with-existing-matrix#comment_183155

say M is 10, then A has 361*10=3610 elements. and B has 3600*10=36000 elements. B has about 32000 extra spots. what do you want to but in the extra spots. If you want to pad them with zeros, use

if you want to make B as a 'collage' of A, use

## Elysi Cochin (view profile)

Direct link to this comment:https://www.mathworks.com/matlabcentral/answers/108390-create-a-matrix-with-existing-matrix#comment_183156

i want to use repmat... but i dont know how to do it when M value varies as you said M can be 10 or 20 or 61 and so..... please can you show me how to do it....

## J Smith (view profile)

Direct link to this comment:https://www.mathworks.com/matlabcentral/answers/108390-create-a-matrix-with-existing-matrix#comment_183157

C to D is straightforward since number of rows in C and D are equal, and D has 4 times the columns in C.

## J Smith (view profile)

Direct link to this comment:https://www.mathworks.com/matlabcentral/answers/108390-create-a-matrix-with-existing-matrix#comment_183158

and for A to B you can use this workaround.

I hope someone gives a straighter solution.

Log in to comment.