当前位置:网站首页>matlab学习2022.7.4
matlab学习2022.7.4
2022-07-05 13:48:00 【megaData】
本人利用假期时间通过《MATLAB应用大全》以及相关视频来学习matlab
常用命令:
clc用来清除命令行窗口的内容
clear用来清除工作空间当中的变量
whos用来显示变量的详细信息
who用来列出工作空间当中的变量名字
利用百分号%进行程序的注释
数据类型:
a1 = int8(6)
a2 = int16(-20)
%int32 int64 为有符号整型
a3 = uint32(100)
a4 = uint64(200)
%uint8 uint16 为无符号整型
b1 = single(3.5)
%单精度浮点型
b2 = 12
%默认为双精度浮点型double
c1 = true
%logical为逻辑型
c2{1,1}=100
%为单元数组类型 cell
c3='hello'
%char 为字符串型
c4.name='robin'
%为结构体类型
[email protected]
%function_handle为函数句柄类型
数值类型:
在matlab当中,默认的数值类型为双精度浮点型
a = 24
%默认变量为双精度浮点型
b1 = int8(a)
b2 = int16(a)
b3 = int32(a)
b4 = int64(a)
c = 'hello'
int8(c)
%将字符串转换为8位的整数
通过函数intmin()和intmax()来得到整数的取值范围
浮点数的取整函数:
round()、fix(向0取整)、floor(不大于该数)、ceil(不小于该数)
a1 = round(2.5)
a2 = round(-2.4)
a3 = round(-2.5)
b1 = fix(-3.6)
b2 = fix(-3.5)
c1 = floor(-4.2)
c2 = floor(4.9)
d1 = ceil(4.2)
d2 = ceil(-4.4)
a = 123.34
b = single(a)
c1 = double(a)
c2 = int16(a)
c3 = int32(a)
d1 = [realmin('single') realmax('single')]
d2 = [realmin('double') realmax('double')]
%通过函数realmin()和realmax()可以得到单精度和双精度浮点型数的取值范围
使用complex(a,b)来创建复数(a为实部,b为虚部)
z1 = 3+4i
a1 = real(z1)
%得到实部
a2 = imag(z1)
%得到虚部
b1 = abs(z1)
%得到复数的模
b2 = angle(z1)
c1 = conj(z1)
%得到共轭复数
z2 = complex(1:3,2:4)
real(z2)
imag(z2)
使用函数format()来确定数值类型的显示格式
默认显示是:format short 保留小数点后4位
format short
a = 12.3456789
format short
a
format long
a
format long e
a
format short e
a
format bank
a
format +
a
format rational
a
format short
%恢复为系统默认显示格式
逻辑类型:
a1 = true
a2 = false
a3 = true(3,4)
a4 = false(3)
clear all
a = 3
logical(a)
b=0
logical(b)
c = [1.3 -3 0;2 0 4;0.01 9 1]
logical(c)
%将数值型转换为逻辑型
字符:
a = 'My name is zhangsan'
b = char([65 66 67 68])
c = int8('hello')
d ='张'
clear all
使用函数句柄来间接调用函数
%函数句柄
f1 = @cos
t = 0:pi/5:pi
f1(t)
f2 = @complex
f2(3,4)
clear all
f1 = @char
s1 = func2str(f1)
f2 = str2func(s1)
functions(f1)
isa(f1,'function_handle')
isequal(f1,f2)
clear all
边栏推荐
- Usage, installation and use of TortoiseSVN
- What is information security? What is included? What is the difference with network security?
- PHP generate Poster
- redis6主从复制及集群
- Matlab paper chart standard format output (dry goods)
- 【MySQL 使用秘籍】一网打尽 MySQL 时间和日期类型与相关操作函数(三)
- Those things I didn't know until I took the postgraduate entrance examination
- When there are too many input boxes such as input transmitted at one time in the form, the post data is intercepted
- Internal JSON-RPC error. {"code":-32000, "message": "execution reverted"} solve the error
- Win10——轻量级小工具
猜你喜欢
基于微信小程序的订餐系统
How to deal with the Yellow Icon during the installation of wampserver
这18个网站能让你的页面背景炫酷起来
[server data recovery] a case of RAID5 data recovery stored in a brand of server
Laravel框架运行报错:No application encryption key has been specified
Redis6 master-slave replication and clustering
Win10 - lightweight gadget
Datapipeline was selected into the 2022 digital intelligence atlas and database development report of China Academy of communications and communications
redis6事务和锁机制
These 18 websites can make your page background cool
随机推荐
什么叫做信息安全?包含哪些内容?与网络安全有什么区别?
运筹说 第68期|2022年最新影响因子正式发布 快看管科领域期刊的变化
MySQL if else use case use
Integer = = the comparison will unpack automatically. This variable cannot be assigned empty
MySQL get time
Log4j utilization correlation
【云资源】云资源安全管理用什么软件好?为什么?
嵌入式软件架构设计-消息交互
restTemplate详解
53. 最大子数组和:给你一个整数数组 nums ,请你找出一个具有最大和的连续子数组(子数组最少包含一个元素),返回其最大和。
Selenium crawls Baidu pictures
我为什么支持 BAT 拆掉「AI 研究院」
These 18 websites can make your page background cool
Elk enterprise log analysis system
网络安全-HSRP协议
Self built shooting range 2022
Redis6 data type and operation summary
Apicloud studio3 WiFi real machine synchronization and WiFi real machine preview instructions
不知道这4种缓存模式,敢说懂缓存吗?
Multi person cooperation project to see how many lines of code each person has written