Matlab to take the model and take the remainder

Source: Internet
Author: User

The MoD function uses the Floor,rem function with the fix function. So what is floor and fix?

  • Fix (x): Truncate rounding. Such as:

>> fix ([3.4,-3.4])

Ans =

3-3

  • Floor (x): Gaussian rounding (no more than the largest integer of x). Such as:

>> floor ([3.4,-3.4])

Ans =

3-4

PS: By the way, the other two rounding functions Ceil () and round ()

Ceil (x): the smallest integer greater than X. Such as:

>> Ceil ([3.4,-3.4])

Ans =

4-3

Round (x): Rounds rounding. Such as:

>> round ([3.4, 3.6,-3.4,-3.6])

Ans =

3 4-3-4

The summary is: fix in the direction of 0 rounding, floor in the negative Infinity direction rounding, ceil in the positive Infinity direction rounding, round rounded to the nearest integer

Here are the things that go back to modulo ...

The formula is: value = divisor-(quotient * divisor) (quotient is obtained through floor function)

such as mod (-1000, 201) =-1000-(-5 * 201) = 5

and mod (1000,-201) = 1000-(-5 *-201) = 5

REM, in the same vein, is calculated using this formula, but it is a fix function. The same applies for decimals.

Matlab to take the model and take the remainder

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.