Assigning multiple groups of matrix entries to a constant value in MATLAB

122 Views Asked by At

Is there a command line in MATLAB that allows one to assign multiple matrix elements to $1$ or any other value?

For example, I set up a $40 \times 40$ matrix with entries $0$ everywhere except at

A(5:19, 1:4)=1
A(23:40, 6:7)=1
A(30:40, 15:40)=1

I would like to assign these elements in one command rather than multiple lines of code. Does anyone have any ideas? Thanks.