当前位置:网站首页>MATLAB学习和实战 随手记
MATLAB学习和实战 随手记
2022-07-06 09:15:00 【@小蜗牛】
简记
1、
str=‘以分号;结尾,不显示这句话’;
str_show=‘不以分号;结尾,则显示当前变量内容’
这是MATLAB的一个特性,如果一条语句以英文分号‘;’结尾,那么这条语句对应的内容或者运行结果不会在命令窗口中被显示,如果没有分号‘;’则会被显示。注意>> 与闪烁的光标一起表明系统就绪,等待输入。
2、
以上是命令行开发的一个小例子,其他值得注意的地方有
在命令窗口Enter键提交命令执行,Shift+Enter可以继续输入命令。
所用运算符(如+、-、^等)是各种计算程序中常见的。
可以直接键入一个表达式(如1+2),计算结果中的ans是英文“answer”的一种缩写,其含义就是“运算答案”。ans是Matlab的一个预定义变量。
3、MATLAB内置输出函数disp(X)
disp函数是MATLAB的内置输出函数,直接调用它可以在命令窗口中输出你想输出的结果X。这里的X可以是各种各样的数据,包括数字、字符、矩阵等等。本关只需要输出一串字符,举个例子,比如在创建的test.m文件中输入以下代码:
4、字符类型的数据是用英文单引号’ ‘来表示的!比如例子里的’你好!’
5、百分号%表示注释,也就是说%后面的内容不参与程序的执行,只作为语句的解释来用
6、变量命名规则
变量名、函数名对字母的大小写是敏感的。如myVar与myvar表示两个不同的变量。
变量名第一个字母必须是英文字母。
变量名可以包含英文字母、下划线和数字。
变量名不能包含空格、标点。
变量名最多可包含63个字符(6.5及以后的版本)。
7、MATLAB用“\”和”/”分别表示“左除”和“右除”。对标量而言,两者没有区别。对矩阵产生不同影响。
8、常用函数
disp(X):用于显示变量X的值,并且不显示变量名称X
num2str(A):用于将数字A转换为字符串,根据这个函数的构造很容易看出它的意思“number to string”,是不是很有意思
另外,还有很多很多有用的函数,这里不做过多的介绍,后面的关卡会慢慢介绍。
input():用于用户对程序内输入数据,具体用法为x = input(prompt)或者str = input(prompt,‘s’),前者表示输入一个数值,后者表示输入一个字符串。当程序运行到这个地方时,在命令窗口内,需要用户输入一个数据,以回车键结束,那么这个数据会存储到x(如果使用的是字符型输入,则存储到str),其中,prompt表示提示语,一般是一个字符串,而且这个字符串必须有(可以为空字符串"")。
边栏推荐
- Valentine's Day flirting with girls to force a small way, one can learn
- Why can't I use the @test annotation after introducing JUnit
- Kept VRRP script, preemptive delay, VIP unicast details
- How to set up voice recognition on the computer with shortcut keys
- Unable to call numpy in pycharm, with an error modulenotfounderror: no module named 'numpy‘
- 使用lambda在循环中传参时,参数总为同一个值
- Error connecting to MySQL database: 2059 - authentication plugin 'caching_ sha2_ The solution of 'password'
- 分布式節點免密登錄
- error C4996: ‘strcpy‘: This function or variable may be unsafe. Consider using strcpy_ s instead
- Codeforces Round #771 (Div. 2)
猜你喜欢

QT creator custom build process

Cookie setting three-day secret free login (run tutorial)

QT creator specifies dependencies

AcWing 242. A simple integer problem (tree array + difference)

MySQL与c语言连接(vs2019版)

Vs2019 use wizard to generate an MFC Application

Connexion sans mot de passe du noeud distribué

Knowledge Q & A based on Apache Jena

Word排版(小计)
![[number theory] divisor](/img/ec/036d7e76cc566c08d336444f2898e1.jpg)
[number theory] divisor
随机推荐
MTCNN人脸检测
Solve the problem of installing failed building wheel for pilot
Why can't I use the @test annotation after introducing JUnit
ES6 let and const commands
AcWing 1298.曹冲养猪 题解
Antlr4 uses keywords as identifiers
Case analysis of data inconsistency caused by Pt OSC table change
QT creator custom build process
Solution of deleting path variable by mistake
Integration test practice (1) theoretical basis
TypeScript
[Presto] Presto parameter configuration optimization
wangeditor富文本引用、表格使用问题
Heating data in data lake?
vs2019 使用向导生成一个MFC应用程序
SQL时间注入
Neo4j installation tutorial
error C4996: ‘strcpy‘: This function or variable may be unsafe. Consider using strcpy_ s instead
数据库高级学习笔记--SQL语句
软件测试与质量学习笔记3--白盒测试