当前位置:网站首页>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
边栏推荐
- 49. 字母异位词分组:给你一个字符串数组,请你将 字母异位词 组合在一起。可以按任意顺序返回结果列表。 字母异位词 是由重新排列源单词的字母得到的一个新单词,所有源单词中的字母通常恰好只用一次。
- 【公开课预告】:视频质量评价基础与实践
- 锚点导航小demo
- Wechat app payment callback processing method PHP logging method, notes. 2020/5/26
- Jetpack compose introduction to mastery
- ETCD数据库源码分析——rawnode简单封装
- asp.net 读取txt文件
- js 从一个数组对象中取key 和value组成一个新的对象
- Idea设置方法注释和类注释
- NFT value and white paper acquisition
猜你喜欢

PHP basic syntax

Idea set method annotation and class annotation

面试官灵魂拷问:为什么代码规范要求 SQL 语句不要过多的 join?

Usage, installation and use of TortoiseSVN

Could not set property 'ID' of 'class xx' with value 'XX' argument type mismatch solution

【云资源】云资源安全管理用什么软件好?为什么?

几款分布式数据库的对比

The development of speech recognition app with uni app is simple and fast.

Datapipeline was selected into the 2022 digital intelligence atlas and database development report of China Academy of communications and communications

::ffff:192.168.31.101 是一个什么地址?
随机推荐
深拷贝真难
Kotlin协程利用CoroutineContext实现网络请求失败后重试逻辑
[public class preview]: basis and practice of video quality evaluation
Idea remote debugging agent
MySQL get time
Don't know these four caching modes, dare you say you understand caching?
kafaka 日志收集
uplad_ Labs first three levels
通讯录(链表实现)
Zhubo Huangyu: it's really bad not to understand these gold frying skills
Usage, installation and use of TortoiseSVN
Laravel generate entity
Primary code audit [no dolls (modification)] assessment
The "Baidu Cup" CTF competition was held in February 2017, Web: explosion-2
链表(简单)
How to divide a large 'tar' archive file into multiple files of a specific size
嵌入式软件架构设计-消息交互
Jetpack compose introduction to mastery
真正的缓存之王,Google Guava 只是弟弟
53. 最大子数组和:给你一个整数数组 nums ,请你找出一个具有最大和的连续子数组(子数组最少包含一个元素),返回其最大和。