1、floor函数:朝负无穷大方向取整
2、用法说明:
y = floor(x) 函数将x中元素取整,值y为不大于本身的最大整数。对于复数,分别对实部和虚部取整
3、用法举例
例1:
>> x = [3+4i 6-7i 9+11i 1-4i 3.4-4.5i 90.67-123i] x = 1.0e+02 * Columns 1 through 5 0.0300 + 0.0400i 0.0600 - 0.0700i 0.0900 + 0.1100i 0.0100 - 0.0400i 0.0340 - 0.0450i Column 6 0.9067 - 1.2300i >> y = floor(x) y = 1.0e+02 * Columns 1 through 5 0.0300 + 0.0400i 0.0600 - 0.0700i 0.0900 + 0.1100i 0.0100 - 0.0400i 0.0300 - 0.0500i Column 6 0.9000 - 1.2300i
例2:
>> a= 2*rand(4) a = 1.9298 0.9708 1.8315 0.0714 0.3152 1.6006 1.5844 1.6983 1.9412 0.2838 1.9190 1.8680 1.9143 0.8435 1.3115 1.3575 >> x = floor(a) x = 1 0 1 0 0 1 1 1 1 0 1 1 1 0 1 1 >> b = floor(a + rand(4)*i) b = 2 1 3 0 1 2 2 1 3 1 3 2 2 2 2 3
4、附录
>> help floor floor Round towards minus infinity. floor(X) rounds the elements of X to the nearest integers towards minus infinity. See also round, ceil, fix. Overloaded methods: codistributed/floor gpuArray/floor Reference page in Help browser doc floor