Matlab学习笔记——矩阵表示

>> x1 = sym('[a,b,c;e,f,g]');     
> %生成符号变量矩阵
>> x2 = sym('[xzcv,qwer,asdf;rqew   fda   vz]');     
> %可以多个字符组合在一起生成一个符号变量,中间有空格会被视为“,>> x1 , x2
 
x1 =
 
[ a, b, c]
[ e, f, g]
 
 
x2 =
 
[ xzcv, qwer, asdf]
[ rqew,  fda,   vz]
 
>> x3 = sym('hhhhh'); x4 = sym('hahaha');  x5 = sym('wwwwww');    
> %sym也可以定义单独一个符号变量
 
>> x6 = [x3,x4,x5;x5,x5,x5;1,2,3]
 
x6 =
 
[  hhhhh, hahaha, wwwwww]
[ wwwwww, wwwwww, wwwwww]
[      1,      2,      3]
 
>> clear x1;    
> %删除变量x1
>> x1 = [1/3,pi;sin(pi),2*pi;log(10),exp(2)] 
> %pi是圆周率,sin(x),log(x)表示以e为底的对数,也可以logN(x)exp(x)当x是数值时表示e^x

x1 =

    0.3333    3.1416
    0.0000    6.2832
    2.3026    7.3891

>> sym(x1)
> %用sym函数可以将矩阵中的数值转化成相应的符号,如pi
 
ans =
 
[                                               1/3,                               pi]
[ 4967757600021511/40564819207303340847894502572032,                             2*pi]
[                 2592480341699211/1125899906842624, 4159668786720471/562949953421312]

简单介绍一下log和exp

>> x1 = log10(100);		
> %logN(x)表示求x关于N为底的对数
>> x2 = exp(0);
> %e^0
>> x3 = exp(1);
> %e
>> x4 = [1,2,3,4,5];
>> x5 = [1,2;3,4], x1, x2, x3, x4

x5 =

     1     2
     3     4


x1 =

     2


x2 =

     1


x3 =

    2.7183


x4 =

     1     2     3     4     5

>> exp(x4)
> %exp可以对行向量进行操作,结果是对向量中每个数进行求e的幂

ans =

    2.7183    7.3891   20.0855   54.5982  148.4132

>> exp(x5)
> %exp可以对矩阵进行操作,结果是对矩阵中每个数进行求e的幂

ans =

    2.7183    7.3891
   20.0855   54.5982

你可能感兴趣的:(其他,Matlab学习笔记,矩阵表示)