How can I change zeros matrix to 1 by specific points??
Show older comments
I have 8X8 Zeros matrix :
A = zeros(8, 8);
I need to create a multiple rectangles of Ones matrix. when I have specific points location:
first rectangular startfrom point [1,1] which are (X0, Y0) to [3,3] which are (X1, Y2).
and
second rectangular start from point [5,5] which are (X0, Y0) to [8,8] which are (X1, Y2).
I have try this but does not work with me:
%%first rectangular
A(([1,1]:[3,1]):([3,1]:[3,3]))= 1
%%second rectangular
A(([5,5]:[8,5]):([8,5]:[8,8]))= 1
Could you please help me.
Accepted Answer
More Answers (1)
Andrei Bobrov
on 27 Nov 2019
A = zeros(8, 8);
A(1:3,1:3) = 1;
A(5:8,5:8) = 1;
1 Comment
Mohammed Alammar
on 28 Nov 2019
Categories
Find more on Resizing and Reshaping Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!