I wanna make 'Az2' matrix 'Az' in the picture.

This is my code for doing that,

`for o=2:1:zmax-1; Az(o,o-1:o+1)=Az2(o,1:3);end`

however, it's way slow… Can I have any other better coding for that as using vectorization? help me…

Skip to content# MATLAB: How to change a matrix as inserting zeroes both end sides

###### Related Question

adiinserting zerosmatrix

I wanna make 'Az2' matrix 'Az' in the picture.

This is my code for doing that,

`for o=2:1:zmax-1; Az(o,o-1:o+1)=Az2(o,1:3);end`

however, it's way slow… Can I have any other better coding for that as using vectorization? help me…

- Hi, can someone help me generate a square matrix with all its elements one, exept its diagonal? As the following
- How to get the secondary diagonal of a matrix
- Sorting matrix by diagonal of submatrix
- How to create a program that reads a matrix array and returns me a second matrix composed of zeros and the main diagonal of the first matrix
- Each diagonal of a matrix

## Best Answer