Write a function called even_indices 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
Show older comments
Problem 3. Write a function called even_indices 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 elements of the n-by-m output matrix are all zeros except for the ones for which both indices are even: these need to be ones. For example, here is an example run:even_indices(5,6) ans = 0 0 0 0 0 0 0 1 0 1 0 1 0 0 0 0 0 0 0 1 0 1 0 1 0 0 0 0 0 0
2 Comments
Steven Lord
on 10 Apr 2017
Show what you've written to try to solve the problem and describe exactly where you're having trouble and you may receive some guidance.
Abdirahman Abdullahi
on 12 Apr 2017
Edited: Abdirahman Abdullahi
on 12 Apr 2017
Accepted Answer
More Answers (2)
Roger Stafford
on 12 Apr 2017
0 votes
Hint: 2:2:n yields only even-valued integers.
1 Comment
Abdirahman Abdullahi
on 12 Apr 2017
Subhasis misra
on 2 Sep 2021
0 votes
Categories
Find more on Creating and Concatenating 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!