天天看點

Matlab reshape,conv,pinv,inv,det函數

reshape():都是将A 的行列排列成m行n列,reshape是 按照列取資料的

https://blog.csdn.net/smf0504/article/details/51811291

>> A = rand(3,4)*10

A =

    8.1472    9.1338    2.7850    9.6489
    9.0579    6.3236    5.4688    1.5761
    1.2699    0.9754    9.5751    9.7059

>> B = reshape(A,2,6)

B =

    8.1472    1.2699    6.3236    2.7850    9.5751    1.5761
    9.0579    9.1338    0.9754    5.4688    9.6489    9.7059

>> B = reshape(A,3,4)

B =

    8.1472    9.1338    2.7850    9.6489
    9.0579    6.3236    5.4688    1.5761
    1.2699    0.9754    9.5751    9.7059

>> 
           

conv():向量卷積計算

https://www.cnblogs.com/hyb221512/p/9276621.html

>> p = rand(1,5)*100

p =

   95.7167   48.5376   80.0280   14.1886   42.1761

>> q = rand(1,4)*100

q =

   91.5736   79.2207   95.9492   65.5741

>> conv(p,q)

ans =

   1.0e+04 *

    0.8765    1.2028    2.0358    1.8573    1.5848    0.9950    0.4977    0.2766

>> conv(q,p)

ans =

   1.0e+04 *

    0.8765    1.2028    2.0358    1.8573    1.5848    0.9950    0.4977    0.2766

>> 
           

pinv():構造僞逆矩陣

inv():構造逆矩陣

https://blog.csdn.net/yinyu19950811/article/details/61420131

>> A =rand(3,5)*10

A =

    0.3571    6.7874    3.9223    7.0605    0.4617
    8.4913    7.5774    6.5548    0.3183    0.9713
    9.3399    7.4313    1.7119    2.7692    8.2346

>> pinv(A)

ans =

   -0.0549    0.0504    0.0276
    0.0436    0.0204    0.0027
    0.0180    0.0772   -0.0535
    0.0933   -0.0604    0.0197
   -0.0122   -0.0713    0.0922

>> B =rand(4,4)*10

B =

    6.9483    4.3874    1.8687    7.0936
    3.1710    3.8156    4.8976    7.5469
    9.5022    7.6552    4.4559    2.7603
    0.3445    7.9520    6.4631    6.7970

>> inv(B)
> %B必須為方陣且是非奇異矩陣

ans =

   -0.0050    0.0802    0.0865   -0.1189
    0.1471   -0.3212   -0.0079    0.2063
   -0.3299    0.3660    0.1231   -0.1122
    0.1418    0.0236   -0.1122    0.0185

>> 
           

det():求行列式

>> A = [1,2,3;4,1,6;4,9,0]

A =

     1     2     3
     4     1     6
     4     9     0

>> det(A)
> %A必須是方陣

ans =

    90

>> 
           

繼續閱讀