Solve $Ax=b$ for $A$ in MATLAB

383 Views Asked by At

I have this linear system

$$\begin{bmatrix} cY(t-1)\\ acY(t-1) - acY(t-2)\end{bmatrix} = T \begin{bmatrix} Y(t-2)\\ Y(t-1)\end{bmatrix}$$

where both $c$ and $a$ are known constants, and I need to find matrix $T$, which is the transformation matrix that transforms the first vector into the second one.

Doing it by hand, this could be seen like

$$\begin{bmatrix} c Y(t-1) + 0 Y(t-2) = u Y(t-1) + v Y(t-2)\\ a c Y(t-1) - a c Y(t-2) = w Y(t-1) + z Y(t-2)\end{bmatrix}$$

with

$$T = \begin{bmatrix} u & v \\ w & z\end{bmatrix} = \begin{bmatrix} 0 & c \\ -ac & ac\end{bmatrix}$$

What I need to do is to solve this in MATLAB, given both $x$ and $b$ vectors, but I can only find how to solve the system for $x$, which is not what I need.

Do you have hints on this?

EDIT: Following given answer I, I may be doing something wrong since the result is not the expected one.

This is what I did to test if I got everything correctly

syms y_t1 y_t2 t1 t2 t3 t4
T = solve(kron([y_t2 y_t1], eye(2))*[t1; t2; t3;t4]==[c_v*y_t1; (a_v*c_v)*(y_t1 - y_t2)], [t1 t2 t3 t4])

The results are:

T.t1 = (2600102520265675*y_t1)/(144115188075855872*y_t2)

T.t2 = (6656262451880127*y_t1 - 6656262451880127*y_t2)/(36893488147419103232*y_t2)

T.t3 = 0

T.t4 = 0

What am I doing wrong?

1

There are 1 best solutions below

13
On

$$\begin{bmatrix} c Y(t-1)\\ a c Y(t-1) - a c Y(t-2)\end{bmatrix} = \underbrace{\begin{bmatrix} 0 & c\\ - ac & ac\end{bmatrix}}_{=T} \begin{bmatrix} Y(t-2)\\ Y(t-1)\end{bmatrix}$$

If you have a system $T y = b$, where $y$ and $b$ are known and $T$ is the unknown, then use vectorization to solve for $T$

$$(y^T \otimes I_2) \operatorname{vec} (T) = b$$

where $y^T \otimes I_2$ is a $2 \times 4$ matrix and $\operatorname{vec} (T)$ is a $4$-dimensional column vector. In MATLAB, use function kron to do the Kronecker product $\otimes$ and reshape to vectorize. Since the $(1,1)$-th entry of $T$ is $0$, then remove the first unknown from this linear system, which yields an underdetermined system of $2$ linear equations in $3$ unknowns.

Since $T$ is only $2 \times 2$, we can solve the linear system by hand. Note that

$$T = \begin{bmatrix} 0 & c\\ - ac & ac\end{bmatrix} = c \begin{bmatrix} 0 & 1\\ - a & a\end{bmatrix} = c \begin{bmatrix} 1 & 0\\ 0 & a\end{bmatrix} \begin{bmatrix} 0 & 1\\ - 1 & 1\end{bmatrix}$$

Hence, $T y = b$ becomes

$$c \begin{bmatrix} 1 & 0\\ 0 & a\end{bmatrix} \begin{bmatrix} y_2\\ y_2 - y_1\end{bmatrix} = \begin{bmatrix} b_1\\ b_2\end{bmatrix}$$

Solving for $a$ and $c$, we obtain

$$a =\frac{b_2}{b_1} \left(\frac{y_2}{y_2- y_1}\right), \qquad{} c= \frac{b_1}{y_2}$$