当前位置:网站首页>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
边栏推荐
- Internal JSON-RPC error. {"code":-32000, "message": "execution reverted"} solve the error
- Multi person cooperation project to see how many lines of code each person has written
- Wonderful express | Tencent cloud database June issue
- 【华南理工大学】考研初试复试资料分享
- 49. 字母异位词分组:给你一个字符串数组,请你将 字母异位词 组合在一起。可以按任意顺序返回结果列表。 字母异位词 是由重新排列源单词的字母得到的一个新单词,所有源单词中的字母通常恰好只用一次。
- 蓝桥杯学习2022.7.5(上午)
- Jasypt configuration file encryption | quick start | actual combat
- Zibll theme external chain redirection go page beautification tutorial
- Programmer growth Chapter 8: do a good job of testing
- Don't know these four caching modes, dare you say you understand caching?
猜你喜欢
那些考研后才知道的事
Introduction to Chapter 8 proof problem of njupt "Xin'an numeral base"
Catch all asynchronous artifact completable future
【公开课预告】:视频质量评价基础与实践
Could not set property 'ID' of 'class xx' with value 'XX' argument type mismatch solution
ZABBIX monitoring
Binder communication process and servicemanager creation process
uplad_ Labs first three levels
MMSeg——Mutli-view时序数据检查与可视化
【华南理工大学】考研初试复试资料分享
随机推荐
Laravel framework operation error: no application encryption key has been specified
锚点导航小demo
Jetpack compose introduction to mastery
Basic characteristics and isolation level of transactions
Requset + BS4 crawling shell listings
2022建筑焊工(建筑特殊工种)特种作业证考试题库及在线模拟考试
Internal JSON-RPC error. {"code":-32000, "message": "execution reverted"} solve the error
Redis6 master-slave replication and clustering
"Baidu Cup" CTF competition in September, web:upload
[public class preview]: basis and practice of video quality evaluation
RK3566添加LED
【公开课预告】:视频质量评价基础与实践
The "Baidu Cup" CTF competition was held in February 2017, Web: explosion-2
Log4j utilization correlation
[notes of in-depth study paper]transbtsv2: wider instead of deep transformer for medical image segmentation
TortoiseSVN使用情形、安装与使用
内网穿透工具 netapp
Solve the problem of invalid uni app configuration page and tabbar
Integer = = the comparison will unpack automatically. This variable cannot be assigned empty
Etcd database source code analysis -- rawnode simple package