MATLAB Answers


overwrite matrix A with matrix B (which has another size)

Asked by Nicole
on 4 Jun 2014
Latest activity Answered by Henric Rydén on 4 Jun 2014


I would like to overwrite matrix_a with an extended matrix_b.

matrix_a has the dimension 19x57 and is full of data.

    matrix_b = [zeros(1,57) matrix_a] 
    matrix_a = matrix_b; 

matrix_a has to be updated and I use this matrix in a loop.

The Error: "Size mismatch (size [57 x 19] ~= size [57 x 20])."

Is there any way to overwrite matrix_a with another matrix with different size?

Thanks! Greeting


Log in to comment.

1 Answer

Answer by Henric Rydén on 4 Jun 2014
 Accepted Answer

matrix_b = [zeros(1,57) matrix_a];
clear matrix_a
matrix_a = matrix_b; 


Log in to comment.

Discover MakerZone

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

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!