当前位置:网站首页>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
边栏推荐
- ::ffff:192.168.31.101 是一个什么地址?
- What about data leakage? " Watson k'7 moves to eliminate security threats
- Win10 - lightweight gadget
- Simple PHP paging implementation
- Embedded software architecture design - message interaction
- Jasypt configuration file encryption | quick start | actual combat
- PHP generate Poster
- ETCD数据库源码分析——集群间网络层客户端peerRt
- Laravel framework operation error: no application encryption key has been specified
- 链表(简单)
猜你喜欢

STM32 reverse entry

法国学者:最优传输理论下对抗攻击可解释性探讨

Introduction to Chapter 8 proof problem of njupt "Xin'an numeral base"

Don't know these four caching modes, dare you say you understand caching?

Assembly language - Beginner's introduction

How to apply the updated fluent 3.0 to applet development

jasypt配置文件加密|快速入门|实战

French scholars: the explicability of counter attack under optimal transmission theory

Record in-depth learning - some bug handling

redis6事务和锁机制
随机推荐
Catch all asynchronous artifact completable future
MySQL if else use case use
Can graduate students not learn English? As long as the score of postgraduate entrance examination English or CET-6 is high!
Those things I didn't know until I took the postgraduate entrance examination
Binder communication process and servicemanager creation process
::ffff:192.168.31.101 是一个什么地址?
Win10——轻量级小工具
【 script secret pour l'utilisation de MySQL 】 un jeu en ligne sur l'heure et le type de date de MySQL et les fonctions d'exploitation connexes (3)
Multi person cooperation project to see how many lines of code each person has written
多人合作项目查看每个人写了多少行代码
[South China University of technology] information sharing of postgraduate entrance examination and re examination
网络安全-HSRP协议
Laravel框架运行报错:No application encryption key has been specified
Elk enterprise log analysis system
Requests + BS4 crawl Douban top250 movie information
Liar report query collection network PHP source code
研究生可以不用学英语?只要考研英语或六级分数高!
ZABBIX monitoring
TortoiseSVN使用情形、安装与使用
49. 字母异位词分组:给你一个字符串数组,请你将 字母异位词 组合在一起。可以按任意顺序返回结果列表。 字母异位词 是由重新排列源单词的字母得到的一个新单词,所有源单词中的字母通常恰好只用一次。