Site icon TestingDocs.com

Matrix multiplication using Octave

Overview

Let’s learn different matrix multiplication using the Octave or Matlab tool. In general, we will discuss two multiplications in this tutorial:

 

>> A = [1 2 3 ; 4 5 6 ; 7 8 9 ];

>> disp(A) 1 2 3 4 5 6 7 8 9

>> R = A.*A ; 

>> disp(R);

1 4 9

16 25 36

49 64 81


>> B = A*A ;

>> disp(B);

30 36 42

66 81 96

102 126 150

>>

 

Element-to-element

We can use the times (.* ) operator for the multiplication. For example:

R = A.*A;

disp(R) ;

Alternatively,

R=times(A,A);

Matrix-to-Matrix

We can perform using the * operator.

C= A*A;


>> A = [1 2 3 ; 4 5 6 ; 7 8 9 ];

>> C= A*A; 

>> disp(A); 

1 2 3 
        
4 5 6 
        
7 8 9 
        
        
>> disp(C); 

30 36 42 
        
66 81 96
        
102 126 150 
        
>>

 

Help and information about Octave is also available on the internet at https://www.octave.org

Exit mobile version