matlab 学习笔记1

demo
help//显示帮助文档
help x//显示x的用法 x可以是运算符或者函数
format long e//命令行直接打,使结果变为15位科学计数法
.*//点乘
......//续行
a=[1,2]//定义向量
a*^b //点乘的乘幂
a\b //左除
// about vectors
A=[1,2]
B=[2,4]
A.^B//a的每个元素按位进行B中对应位置的乘幂 得到[1,16]
//一些常量
eps
pi
about function
function f=fun(x)// name the .m document the same name with your function
f=3*x+sin(x)-6*log(x)//log==ln
//
x=first:step_length:end;//like: x=1:2:50
x=linspace(first:end:n)//divid [first,end] into n-1 parts,chose every ends as the elements in x

image

//about matrix
A=B'//A==B's transposition
a=zeros(m,n)//produce an empty matrix
a=ones(m,n)//1 matrix
a=eye(m,n)//单位矩阵
a=rand(m,n)//每个元素都是0,1之间的随机数
A(r,:)//取第r行
A(:,r)//取第r列
A(:)//取每一列,做成长列向量

//still about matirx
A(i:j,m:n)//取i到j行,m到n列
A(i:-1:j,m:n)//逆序取i到j行的元素(i>j)
A(i:j,:)=[]//delete elements in line[i,j]
inv(A)//inverse
det(A)//行列式

image

posted @ 2023-02-28 10:49  wxk123  阅读(33)  评论(0)    收藏  举报