md_files/科研/matlab.md
2025-03-19 18:31:37 +08:00

49 lines
957 B
Markdown
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

## matlab笔记
#### 命令行窗口
clc清屏命令行窗口
clear all:把命名的变量删掉,不是命令行窗口
#### 命名规则:
变量命名以字母开头,不可以下划线,变量是区分字母大小写的
#### 脚本
%% xxx 注释(百分号+一个空格)
% xxx 也是注释
s='a' '"aaaa",字符串
abs(s) 字符s的ascii码,为97
char(97), 输出'a'
numtostr(65) ans='65',数字转字符串
length(str),字符串的长度
#### 矩阵
A=[1 2 3 ;4 5 6 ;7 8 9] 分号换行
B=A ,矩阵转置
C=A(:) ,将矩阵拉成一列,按列存储,第一列拼接第二列拼接第三列
D=inv(A) 求逆矩阵
E=zeros(10,5,3) 生成10行5列3维0矩阵
![](https://pic.bitday.top/i/2025/03/19/u80led-2.png)
#### 元胞数组
A=cell(1,6)生成1行6列的小格子每个小格子可以存放各种数据
eye(3),生成3x3的单位阵
A{2}=eye(3),matlab数组从1开始不是0