matlab裏面的取整函數(fix,round,floor……
在對數據進行處理時,有時我們需要對含有小數的數據進行取整處理,本例分享matlab裏面常用的幾種取整函數,fix、round、floor、ceil
操作方法
(01)fix-向零方向取整。fix Round towards (X) rounds the elements of X to the nearest integerstowards zero.
(02)fix使用舉例:t =7.6806 3.5388 3.6130 9.0150 8.1769 3.17812.3309 3.4719 7.4163 3.1834 9.8118 9.84455.8736 2.5372 7.0590 5.9708 8.6199 5.48254.5897 9.5253 7.0089 2.9780 0.8382 7.49258.6098 2.9820 0.0623 1.2501 3.3771 8.41856.6084 1.5841 3.7435 3.8836 2.3613 1.6689-----------------------------------------------------------------------fix(t)ans =7 3 3 9 8 32 3 7 3 9 95 2 7 5 8 54 9 7 2 0 78 2 0 1 3 86 1 3 3 2 1
(03)round-向最近的方向取整。round Round towards nearest d(X) rounds the elements of X to the nearest integers.
(04)floor-向負無窮大方向取整:floor Round towards minus r(X) rounds the elements of X to the nearest integerstowards minus infinity.
(05)ceil-向正無窮大方向取整。ceil Round towards plus (X) rounds the elements of X to the nearest integerstowards infinity.
(06)mod-計算模數:mod Modulus after (x,y) is x - n.*y where n = floor(x./y) if y ~= 0. If y is not aninteger and the quotient x./y is within roundoff error of an integer,then n is that integer. The inputs x and y must be real arrays of thesame size, or real statement "x and y are congruent mod m" means mod(x,m) == mod(y,m) convention:mod(x,0) is (x,x) is (x,y), for x~=y and y~=0, has the same sign as : REM(x,y), for x~=y and y~=0, has the same sign as (x,y) and REM(x,y) are equal if x and y have the same sign, butdiffer by y if x and y have different signs.
特別提示
rem函數可以計算餘數(真實的餘數,可以是任意實數)
-
包糉子的材料有什麼
(01)包糉子是中國傳統節日端午節的傳統食品之一,通常由糯米、肉、豆沙等食材製成。以下是包糉子的材料:1.糯米:糯米是包糉子的主要原料,也是糉子口感和質地的基礎。糯米需要提前浸泡幾個小時,然後瀝乾水分備用。(02)2.豬肉:豬肉是包糉子常用的肉類食材之一,可以根據個人口...
-
最好養的熱帶魚排行 十大養不死的熱帶魚盤點
導語:很多人都想在家裏養魚,但是養魚也並不是那麼簡單的,所以很多人開始就會選擇比較好樣的魚。熱帶魚不僅好看而且對環境要求比較小,那麼最好養的熱帶魚有哪些?探祕志帶大家瞭解十大養不死的熱帶魚吧。1、月光魚第一個進入最好養的熱帶魚排行是月光魚,這是一種比較...
-
世界最值錢甲蟲:陽彩臂金龜一隻幾十萬(曾經滅絕)
導語:說到昆蟲,大家可能只能想到世界十大最毒昆蟲或者世界上最兇殘的昆蟲之類的,假如說最值錢,很多人覺得是在開玩笑吧,畢竟小小的蟲子難道還有人花大價錢去購買嗎?你別說還真有,下面探祕志小編爲大家介紹一下世界上最值錢的甲蟲,一隻幾十萬哦。陽彩臂金龜陽彩臂金龜...
-
國內充電樁企業10強
(01)根據不同的排名和數據來源,國內充電樁企業10強可能會有所不同,但以下是一些較爲知名的充電樁企業:1.特來電:特來電是青島特銳德電氣股份有限公司旗下的品牌,業務覆蓋新能源汽車充電網的建設、運營及互聯網增值服務。截至2020年,特來電充電樁總數爲15.7萬臺,位居全國...