当前位置:网站首页>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
边栏推荐
- 龙芯派2代烧写PMON和重装系统
- leetcode 10. Regular Expression Matching 正则表达式匹配 (困难)
- Address book (linked list implementation)
- Idea set method annotation and class annotation
- ::ffff:192.168.31.101 是一个什么地址?
- Win10——轻量级小工具
- Kotlin collaboration uses coroutinecontext to implement the retry logic after a network request fails
- restTemplate详解
- PHP character capture notes 2020-09-14
- 锚点导航小demo
猜你喜欢

Summit review | baowanda - an integrated data security protection system driven by compliance and security

Usage, installation and use of TortoiseSVN

These 18 websites can make your page background cool

【公开课预告】:视频质量评价基础与实践

Assembly language - Beginner's introduction

laravel-dompdf导出pdf,中文乱码问题解决

Operational research 68 | the latest impact factors in 2022 were officially released. Changes in journals in the field of rapid care

内网穿透工具 netapp

Jasypt configuration file encryption | quick start | actual combat

不知道这4种缓存模式,敢说懂缓存吗?
随机推荐
Rk3566 add LED
Elk enterprise log analysis system
ETCD数据库源码分析——集群间网络层客户端peerRt
【MySQL 使用秘籍】一網打盡 MySQL 時間和日期類型與相關操作函數(三)
Zhubo Huangyu: these spot gold investment skills are not really bad
龙芯派2代烧写PMON和重装系统
Attack and defense world web WP
Requset + BS4 crawling shell listings
:: ffff:192.168.31.101 what address is it?
不知道这4种缓存模式,敢说懂缓存吗?
Can graduate students not learn English? As long as the score of postgraduate entrance examination English or CET-6 is high!
基于微信小程序的订餐系统
Introduction to Chapter 8 proof problem of njupt "Xin'an numeral base"
When using Tencent cloud for the first time, you can only use webshell connection instead of SSH connection.
Godson 2nd generation burn PMON and reload system
French scholars: the explicability of counter attack under optimal transmission theory
The development of speech recognition app with uni app is simple and fast.
Kotlin collaboration uses coroutinecontext to implement the retry logic after a network request fails
js 从一个数组对象中取key 和value组成一个新的对象
Laravel generate entity