Trying to write functions on Matlab

36 Views Asked by At

Im just learning matlab. I was wondering how can we make Matlab functions to perform $ABx$ is two ways: $(AB)x $ and $A(Bx)$ where $A,B$ are $n \times n$ matrices. I am stuck on trying to write these codes as I am not familiar with programming. Can someone help me?

1

There are 1 best solutions below

0
On

I would just define a new matrix:


A = [];
B = [];
x = [];
C = A*B;
D = B*x;
C*x
A*D

The last two outputs should be identical.