导航:首页 > 使用方法 > matlab中函数的使用方法

matlab中函数的使用方法

发布时间:2025-03-17 07:06:23

Ⅰ matlab中round函数具体用法

round函数

函数功能:四舍五入取整。

使用方法:B = round(A)

对数组A中每个元素朝最近的方向取整数部分,并返回与A同维的整数数组B,对于一个复数参量A,则分别对其实部和虚数朝最近的方向取整数部分,并返回一复数数据B。

例子:

ceil(x)返回不小于x的最小整数值(然后转换为double型)。

floor(x)返回不大于x的最大整数值。

round(x)返回x的四舍五入整数值。

#include <stdio.h>

#include <math.h>

int 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.out

ceil(1.499900) is 2.000000

floor(1.499900) is 1.000000

round(1.499900) is 1.000000

Matlab中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.6000

Columns 5 through 6

7.0000 2.4000 + 3.6000i

round(a)

ans =

Columns 1 through 4

-2.0000 0 3.0000 6.0000

Columns 5 through 6

7.0000 2.0000 + 4.0000i

阅读全文

与matlab中函数的使用方法相关的资料

热点内容
多快蓝牙电池连接方法 浏览:530
苹果助手怎么共享网络设置在哪里设置方法 浏览:532
调整汽车灯光的方法和步骤 浏览:656
桃牙治疗的最好方法 浏览:663
汽油机水泵反转解决方法 浏览:474
什么方法更容易且更最快去除甲醛 浏览:747
换水瓶的贴纸正确方法视频 浏览:585
装配式建筑有哪些方法 浏览:853
扁桃体肿大的快速治疗方法 浏览:879
勾腹拳的正确方法 浏览:93
国外用什么方法捕鱼 浏览:934
手机断流断触解决方法 浏览:881
540除以45的简便方法 浏览:318
华为手机电池虚电解决方法 浏览:661
我国教学方法研究思路 浏览:419
安全带的正确方法图片 浏览:795
尿道内尖锐怎么治疗最好的方法 浏览:694
楼内pvc下水道安装方法 浏览:655
女性洗头用什么方法吹干 浏览:558
哪些情况应对检验方法进行验证 浏览:800