当前位置:网站首页>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
边栏推荐
- matlab 取整
- Picture rotation move zoom gradient
- Ecological escort cloud service providers wave "Intel flag"
- Première application de l'informatique quantique à la modélisation des flux de puissance dans les systèmes énergétiques à l'Université technique danoise
- 利用 Redis 的 sorted set 做每周热评的功能
- 音频PCM数据计算声音分贝值,实现简单VAD功能
- Scala trait exercise
- php easywechat 和 小程序 实现 长久订阅消息推送
- Reading notes at night -- deep into virtual function
- [practical series] full WiFi coverage at home
猜你喜欢

Basic knowledge of assembly language (2) -debug

4 years of working experience, and you can't tell the five communication modes between multithreads. Can you believe it?

Boutique enterprise class powerbi application pipeline deployment

汇编语言(2)基础知识-debug

4年工作经验,多线程间的5种通信方式都说不出来,你敢信?

新一代可级联的以太网远程I/O数据采集模块

PMP考试“临门一脚”如何踢得漂亮?

Cobalt Strike安装教程

TC对象结构和简称

2022 simulated 100 questions of safety officer-c certificate examination and online simulated examination
随机推荐
Library management system code source code (php+css+js+mysql) complete code source code
汇编语言(2)基础知识-debug
Bi SQL drop & alter
lnmp环境安装ffmpeg,并在Yii2中使用
卷积与反卷积关系超详细说明及推导(反卷积又称转置卷积、分数步长卷积)
Why does Dell always refuse to push the ultra-thin commercial notebook to the extreme?
Novice, let me show you the "soft test" at one time
Bi-sql like
AutoCAD - two extension modes
Bi-sql Union
联想童夫尧:11倍于大势,我们一路攻城拔寨
启动服务11111
程序员:是花光积蓄在深圳买房?还是回到长沙过“富余”生活?
Cobalt Strike安装教程
Add information on the left and add parts on the right of the status bar
TC对象结构和简称
Scala sample class
LLVM TargetPassConfig
腾讯云WeCity丨你好 2022!
[practical series] full WiFi coverage at home