当前位置:网站首页>Matlab rounding
Matlab rounding
2022-06-25 01:18:00 【The sheep said it was okay】
One 、 Integral function
1. Round to zero ( To round off )
fix- Round to zero (Round towards zero);
fix(3.6)
ans = 3
2. Rounding negative infinity ( No more than x Maximum integer for - Gauss rounding )
floor- Rounding negative infinity (Round towards minus infinity);
floor(-3.6)
ans = -4
3. Rounding to positive infinity ( Greater than x Minimum integer of )
ceil- Rounding to positive infinity (Round towards plus infinity);
ceil(-3.6)
ans = -3
4. Round to the nearest integer , rounding ( Round to the nearest whole )
round- Round to the nearest integer , rounding (Round towards nearest integer);
round(3.5)
ans = 4
Two 、 Round to a certain place after the decimal point , Keep a few decimal places , It's often used .
1. Numerical type roundn— Round any bit position
a=123.4567890;
a=roundn(a,-4)
a = 123.4568
among roundn The functions are as follows :
y = ROUNDN(x) rounds the input data x to the nearest hundredth. % Don't specify n, To the hundredth y = ROUNDN(x,n) rounds the input data x at the specified power % The number of digits specified after the decimal point n
2. Semiotic type
digits(4)
vpa(…)
Must explain :vpa The command does not recognize integers and decimals , Just the total number of digits , So for it, decimal and integer numbers occupy one place , For example 9.3154 If you keep two decimal places, you have to write :
a=9.3154;
digits(3)
b=vpa(a)
b= 9.32
among b Is a symbolic variable ;
3. Character
a=12.34567;
b = fprintf(‘%8.2f’,a)
b = 12.35 among b Is a character variable .
matlab Text output
Two functions :disp fprintf
1、 function disp With just one variable , It can be a conceited matrix or a numerical matrix , To output a simple text message , Just enclose the information in single quotation marks :
disp(‘my favorite color is red’);
perhaps
yourname=input(‘enter your name’,‘s’);
disp([‘your name is’,youname]);
for example
yourname = input('enter your name ',‘s’);
enter your name panrq
disp(['your name is ',yourname]);
your name is panrq
When selecting text information with numeric variable values , You need to use the function num2str Convert the type of numeric variable to character type
x=98;
outstring = ['x = ',num2str(x)];
disp(outstring);
x = 98
disp(['x = ',num2str(x)]);
x = 98
disp Function can only take one variable , The columns in the table need to be combined into a matrix , As shown in the following procedure .
x=0:pi/5:pi;y=sin(x);
disp([x’ y’]);
0 0
0.6283 0.5878
1.2566 0.9511
1.8850 0.9511
2.5133 0.5878
3.1416 0.0000
Format command
Control the display mode , Until the next format Before it appeared , This article format The order has been in effect .
x=1.23456789;
format short;disp(pi);
3.1416
format long;disp(pi);
3.141592653589793
format short e;disp(pi);
3.1416e+000
format +;disp(pi);
format bank;disp(pi);
3.14
2、 function fprintf
fprintf(format);
fprintf(format,variables);
fprintf(fid,format,variables);
for example :
fprintf(‘i am concreten’);
i am concrete
a=3;b=‘s’;
fprintf(‘this is a %d and %s n’,a,b);
this is a 3 and s
边栏推荐
- yasea apk 下载 镜像
- Danish Technical University pioneered the application of quantum computing to power flow modeling of energy system
- 新手看过来,带你一次性了解“软考”
- Using macro code to generate handwriting automatically in word or WPS
- Super detailed description and derivation of convolution and deconvolution (deconvolution is also called transpose convolution and fractional step convolution)
- 期望与方差
- Bi SQL alias
- 卷积与转置卷积
- Distinguish between i++ and ++i seconds
- ContentResolver,拿到手机短信内容
猜你喜欢
Boutique enterprise class powerbi application pipeline deployment
Scala IO read by line
Bi-sql between
Ideas and examples of divide and conquer
Cobalt strike installation tutorial
Bi-sql Union
Deep learning LSTM model for stock analysis and prediction
丹麥技術大學首創將量子計算應用於能源系統潮流建模
Text border format and text block of rich text
LLVM TargetPassConfig
随机推荐
Scala adapter pattern
Scala IO read by line
腾讯云WeCity丨你好 2022!
归并排序模板 & 理解
Scala sample class case calculate
Super detailed description and derivation of convolution and deconvolution (deconvolution is also called transpose convolution and fractional step convolution)
Bi-sql between
Why does Dell always refuse to push the ultra-thin commercial notebook to the extreme?
启动服务11111
php easywechat 和 小程序 实现 长久订阅消息推送
高考之后,必然会出现以下四种情况:
天书夜读笔记——内存分页机制
C语言边界计算和不对称边界
51 single chip microcomputer multi computer communication
activity生命周期
void* 指针
Basic knowledge of assembly language (2) -debug
2种常见的设备稼动率OEE监测方法
Linux64Bit下安装MySQL5.6-不能修改root密码
Properties of DOM