matlab中round函數的用法(matlab中round函數具體用法)

導讀您好,現在軟糖來為大家解答以上的問題。matlab中round函數的用法,matlab中round函數具體用法相信很多小伙伴還不知道,現在讓我們一起來看看...

您好,現在軟糖來為大家解答以上的問題。matlab中round函數的用法,matlab中round函數具體用法相信很多小伙伴還不知道,現在讓我們一起來看看吧!

1、round函數函數功能:四舍五入取整。

2、使用方法:B = round(A)對數組A中每個元素朝最近的方向取整數部分,并返回與A同維的整數數組B,對于一個復數參量A,則分別對其實部和虛數朝最近的方向取整數部分,并返回一復數數據B。

3、例子:ceil(x)返回不小于x的最小整數值(然后轉換為double型)。

4、floor(x)返回不大于x的最大整數值。

5、round(x)返回x的四舍五入整數值。

6、#include#includeint main(int argc, const char *argv[])float num = 1.4999;printf("ceil(%f) is %f", num, ceil(num));printf("floor(%f) is %f", num, floor(num));printf("round(%f) is %f", num, round(num));return 0;}編譯:$cc test.c -lm執行:$./a.outceil(1.499900) is 2.000000floor(1.499900) is 1.000000round(1.499900) is 1.000000Matlab中round()應用舉例:a = [-1.9, -0.2, 3.4, 5.6, 7.0, 2.4+3.6i]a =Columns 1 through 4-1.9000 -0.2000 3.4000 5.6000Columns 5 through 67.0000 2.4000 + 3.6000iround(a)ans =Columns 1 through 4-2.0000 0 3.0000 6.0000Columns 5 through 67.0000 2.0000 + 4.0000i。

本文就為大家分享到這里,希望小伙伴們會喜歡。

免責聲明:本文由用戶上傳,如有侵權請聯系刪除!