2013-10-23 24 views
0

我在八度音程兩個列向量:在八度乘以2個columnvectors

a=[1;2;3;4;5;6;7] 

b=[7;6;5;4;3;2;1] 

我想乘這兩個向量:

A * B和A * B」既給了錯誤:

error: operator *: nonconformant arguments (op1 is 7x1, op2 is 7x1) 

我做錯了什麼?

+1

嘗試*(B')...... – apomene

+0

嘗試重新啓動八度,'一* b''應該工作。你正在運行什麼版本? – Dan

回答

0

a*b不起作用,因爲您無法將7x1向量乘以7x1向量。正如在評論中提到的那樣,a*b'的作品(因爲現在你乘以1x7矢量的7x1矢量,導致7x7矩陣),因此a.*b(單元乘法)。下面是我得到倍頻3.6.2:

>> a*b 
error: operator *: nonconformant arguments (op1 is 7x1, op2 is 7x1) 
>> a*b' 
ans = 

    7 6 5 4 3 2 1 
    14 12 10 8 6 4 2 
    21 18 15 12 9 6 3 
    28 24 20 16 12 8 4 
    35 30 25 20 15 10 5 
    42 36 30 24 18 12 6 
    49 42 35 28 21 14 7 

>> a.*b 
ans = 

    7 
    12 
    15 
    16 
    15 
    12 
    7