也是很久没写过markdown了,康复训练吧
A=‘b’
abs (A) %对A所代表的字符ASCII码值取绝对值
char(65) %命令行窗口显示A
num2str(65) %命令行窗口显示65,num2str是个函数
str='I LOVE MATLAB'
length(str) %计算str字符串长度(注意空格也算字符)
clc
clear all
A=[ 2 3 4 ; 6 3 7 ; 7 5 3] %创建矩阵
B=A' %求A的转置矩阵
C=A(:) %将A矩阵竖着下拉
D=inv(A) %求A的逆矩阵A的“-1次”
此时A*D就是AxA逆=
clc
clear all
A=zeros(10,5,3) %生成一个3维的10行5列的零矩阵
A(:,:,1)=rand(10,5)
A(:,:,2)=randi(5,10,5)
A(:,:,3)=randn(10,5)
第三行的结果如下
A(:,:,1) =
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
A(:,:,2) =
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
A(:,:,3) =
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
第四行第五行第六行3rand的区别
A(:,:,1)=rand(10,5) %第一维矩阵生成10行5列的均匀分布的伪随机数矩阵
A(:,:,2)=randi(5,10,5) %第二维矩阵生成在(0,5)开区间生成10x5的随机矩阵
A(:,:,3)=randn(10,5) %第三维矩阵生成10行5列的标准正态分布的伪随机数矩阵(均值0,方差1)
A(:,:,1)=rand(10,5) %第一维矩阵生成10行5列的均匀分布的伪随机数矩阵
A(:,:,1) =
0.8147 0.1576 0.6557 0.7060 0.4387
0.9058 0.9706 0.0357 0.0318 0.3816
0.1270 0.9572 0.8491 0.2769 0.7655
0.9134 0.4854 0.9340 0.0462 0.7952
0.6324 0.8003 0.6787 0.0971 0.1869
0.0975 0.1419 0.7577 0.8235 0.4898
0.2785 0.4218 0.7431 0.6948 0.4456
0.5469 0.9157 0.3922 0.3171 0.6463
0.9575 0.7922 0.6555 0.9502 0.7094
0.9649 0.9595 0.1712 0.0344 0.7547
A(:,:,2) =
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
A(:,:,3) =
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
A(:,:,2)=randi(5,10,5) %第二维矩阵生成在(0,5)开区间生成10x5的随机矩阵
A(:,:,1) =
0.8147 0.1576 0.6557 0.7060 0.4387
0.9058 0.9706 0.0357 0.0318 0.3816
0.1270 0.9572 0.8491 0.2769 0.7655
0.9134 0.4854 0.9340 0.0462 0.7952
0.6324 0.8003 0.6787 0.0971 0.1869
0.0975 0.1419 0.7577 0.8235 0.4898
0.2785 0.4218 0.7431 0.6948 0.4456
0.5469 0.9157 0.3922 0.3171 0.6463
0.9575 0.7922 0.6555 0.9502 0.7094
0.9649 0.9595 0.1712 0.0344 0.7547
A(:,:,2) =
2 4 5 2 1
4 2 2 5 1
4 3 5 3 3
1 4 2 3 4
1 5 5 5 5
3 5 2 2 1
5 3 1 4 3
2 1 2 4 3
3 1 4 2 1
2 2 3 3 2
A(:,:,3) =
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
A(:,:,3)=randn(10,5) %第三维矩阵生成10行5列的标准正态分布的伪随机数矩阵(均值0,方差1)
A(:,:,1) =
0.8147 0.1576 0.6557 0.7060 0.4387
0.9058 0.9706 0.0357 0.0318 0.3816
0.1270 0.9572 0.8491 0.2769 0.7655
0.9134 0.4854 0.9340 0.0462 0.7952
0.6324 0.8003 0.6787 0.0971 0.1869
0.0975 0.1419 0.7577 0.8235 0.4898
0.2785 0.4218 0.7431 0.6948 0.4456
0.5469 0.9157 0.3922 0.3171 0.6463
0.9575 0.7922 0.6555 0.9502 0.7094
0.9649 0.9595 0.1712 0.0344 0.7547
A(:,:,2) =
2 4 5 2 1
4 2 2 5 1
4 3 5 3 3
1 4 2 3 4
1 5 5 5 5
3 5 2 2 1
5 3 1 4 3
2 1 2 4 3
3 1 4 2 1
2 2 3 3 2
A(:,:,3) =
-1.7947 -0.1941 -1.2078 -2.0518 -0.2991
0.8404 -2.1384 2.9080 -0.3538 0.0229
-0.8880 -0.8396 0.8252 -0.8236 -0.2620
0.1001 1.3546 1.3790 -1.5771 -1.7502
-0.5445 -1.0722 -1.0582 0.5080 -0.2857
0.3035 0.9610 -0.4686 0.2820 -0.8314
-0.6003 0.1240 -0.2725 0.0335 -0.9792
0.4900 1.4367 1.0984 -1.3337 -1.1564
0.7394 -1.9609 -0.2779 1.1275 -0.5336
1.7119 -0.1977 0.7015 0.3502 -2.0026
好了,边学边记笔记,掌握才是最重要的!