zoukankan      html  css  js  c++  java
  • MATLAB中的取整函数(fix、round、floor、ceil)

    • fix - 向零方向取整

    fix Round towards zero.
        fix(X) rounds the elements of X to the nearest integers towards zero.

    例:

    t =

    7.6806 3.5388 3.6130
    2.3309 3.4719 7.4163
    5.8736 2.5372 7.0590

    fix(t)

    ans =

    7 3 3
    2 3 7
    5 2 7

    • round - 向最近的方向取整,亦即“四舍五入”

    round rounds towards nearest decimal or integer
        round(X) rounds each element of X to the nearest integer.

    例:

    t =

    7.6806 3.5388 3.6130
    2.3309 3.4719 7.4163
    5.8736 2.5372 7.0590

    round(t)

    ans =

    8 4 4
    2 3 7
    6 3 7

    • floor - 向负无穷大方向取整

    floor Round towards minus infinity.
        floor(X) rounds the elements of X to the nearest integers towards minus infinity.

    例:

    t =

    7.6806 3.5388 3.6130
    2.3309 3.4719 7.4163
    5.8736 2.5372 7.0590

    floor(t)

    ans =

    7 3 3
    2 3 7
    5 2 7

    • ceil - 向正无穷大方向取整

    ceil Round towards plus infinity.
        ceil(X) rounds the elements of X to the nearest integers towards infinity.

    t =

    7.6806 3.5388 3.6130
    2.3309 3.4719 7.4163
    5.8736 2.5372 7.0590

    ceil(t)

    ans =

    8 4 4
    3 4 8
    6 3 8

  • 相关阅读:
    poj 1840 简单哈希
    poj 2151概率dp
    poj 3349 简单hash
    poj3274 hash
    poj 1459 最大流 Dinic模板题
    poj 3436 最大流-拆点
    poj 3020 二分图最大匹配
    poj 1094 简单拓扑排序
    poj3687 反向建图拓扑排序
    poj 3267
  • 原文地址:https://www.cnblogs.com/avin/p/7068594.html
Copyright © 2011-2022 走看看