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

# if we enter n rows and m colums and gets the output of 2n rows and 2m columns

Write a function named blocks that takes two positive integers, n and m, as input arguments (the function does not have to check the format of the input) and returns one matrix as an output argument. The function needs to return a 2n-by-2m matrix where the upper right and lower left n-by m sub matrices are all zeros and the rest of the matrix are all ones.

## Products

No products are associated with this question.

Answer by Andrei Bobrov on 27 Jun 2013
Edited by Andrei Bobrov on 27 Jun 2013

Dear Andrei Bobrov My name is Jawad Durrani and I am doing MS in electrical communication. I have completed my course work and doing research now a days. I am learning Matlab for my research. I am studying the book "Computer Programming with Matlab by Michael Fitzpatrick and Akos Ledeczi" This is not my homework. Its one of the exercise problem. I already done by using built in function zeros and ones But i want to do it without using built in functions I hope you understand. Regards

Andrei Bobrov on 4 Jul 2013
```n = 5;
m = 3;
out = zeros([n m]*2);
for jj = 1:2
out((jj-1)*n+(1:n),(jj-1)*m+(1:m)) = 1;
end
```