Write a function called alternate that takes two positive integers, n and m, as input arguments...

50.1K

Verified Solution

Question

Advance Math

Write a function called alternate that takes two positiveintegers, n and m, as input arguments (the function does not haveto check the format of the input) and returns one matrix as anoutput argument. Each element of the n-by-m output matrix for whichthe sum of its indices is even is 1. All other elements are zero.For example, here is an example run:

>> alternate(4,5)

ans =

1 0 1 0 1

0 1 0 1 0

1 0 1 0 1

0 1 0 1 0

Once again, using the zeros function can help,but it is not necessary

Answer & Explanation Solved by verified expert
3.6 Ratings (677 Votes)
If you have any queries let me know through thecommentsI have given the code for your requirementsOf course I have executed the code snippet withthe random values and it give the as expected    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students