I have a matrice A 15*15 with random numbers , i wanna put zeros in arrays outside A(5:8,5:8) ,how can i do this?

I have a matrice A 15*15 with random numbers , i wanna put zeros in arrays outside A(5:8,5:8) ,how can i do this?

Answers (1)

One way:
A = rand(15);
B = zeros(15);
B(5:8, 5:8) = A(5:8, 5:8);
A = B;

1 Comment

Looks like it does the job. Akshit might want to Accept it to give you Reputation points, and might also accept some/most of his other questions also.

Sign in to comment.

Categories

Asked:

on 10 Mar 2015

Commented:

on 10 Mar 2015

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!