MATLAB 4 - Matlab 4 Even or Odd What for Tian Gu ID...

Info icon This preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Matlab 4 Even or Odd? What for? Tian Gu ID: 853324472 Team partner: Tielong Su The Modulus Function – mod About the new function ‘mod’ We try to use ‘help’ and ‘doc’ to find the what mod does. Modulus after division is the definition in help and doc. But we are still confused about the descriptions. And what exactly modulus is? Then we use search Modulo operation by Wikipedia. It gives the description of ‘ remainder’ which is more easily to understand. We connected the examples in ‘help’ and ‘doc’. So we think this new function is used to get the remainder of division. Looking back to the examples in ‘doc’, now we try to explain them. Example 1: mod(13,5) ans = 3 Here, 13 is the dividend, and 5 is the divisor, we use the function ‘mod(13,5)’ to find the remainder of this division is 3. Comparing to the example which the guide gives us, we can find they are similar. >> mod(8,3) ans = 2 8 is the dividend, and 3 is the divisor (8/3). So, we get the remainder 2. Example 2: mod([1:5],3) ans = 1 2 0 1 2 This example in ‘doc’ is a little different. [1:5] is the dividend. So what we do is using 1~5 as the dividend one after another. Finally we can find all remainders. Even or Odd The program we need to write is distinguish if an integer is odd or even. We should make the user input a integer, so we start with, numb = input('Please input an integer number:','s'); We can use the new function ‘mod’ to indentify the integer according the reminder of dividing the number by 2.
Image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern