matlab: how to solve this linear system I have 2 vectors that are scalar multiples of each other but their components have an unknown 'z'.
ie 
v1=[a, bz+c, e-zd ] 
v2=[e, fz+g, h+z] 

Only z is a variable/unknown, the rest are just numeric coefficients. How do i solve this using matlab??
I tried using linsolve but it doesnt seem to support symbolic arguments (z).
 A: $k$ and $z$ can be found fairly quickly by hand. However, since you are interested in formulating it using Matlab, let us consider that instead. The equations to be solved are 
\begin{align}
a &= k e \\
b z + c &= k (f z + g) \\
e - z d &= k (h + z),
\end{align}
where $k$ is some unknown constant of proportionality. Note: Since $k$ and $z$ are both unknowns, this is no longer a system of linear equations; instead it is a system of nonlinear equations. To formulate this in Matlab, we can use fsolve. First let us reformulate the problem as follows. First 
\begin{align}
a - k e &= 0 \\
b z + c - k (f z + g) &= 0 \\
e - z d - k (h + z) &= 0.
\end{align}
The system of nonlinear equations can now be formulated as solving the equation $\textbf{F}(\textbf{x}) = \textbf{0}$, where 
\begin{equation}
\textbf{F}(\textbf{x}) = \begin{bmatrix} a - k e \\ b z + c - k (f z + g) \\ e - z d - k (h + z) \end{bmatrix} \text{ and } \textbf{x} = \begin{bmatrix} k \\ z \end{bmatrix}.
\end{equation}
For example, to use fsolve to solve the above function, you could type
[x, fval, exitflag] = fsolve(@(x) [a - x(1)*e; b*x(2) + c - x(1)*(f*x(2) + g); e - x(2)*d - x(1)*(h + x(1))], [0; 0])

where the initial guess for the solver is x0 = [0; 0], the solution (if it exists) is x, fval should be approximately equal to 0, and exitflag describes if fsolve was able to find a solution (see the fsolve help page for more info). If there is no solution, then you might need to do some nonlinear optimization, but hopefully there will be a solution.
A: Your system of equations can be written as
$$
V =
\left ( \begin{array}{ccc}
a & bz+c & e-zd \\
e & fz+g & h+z
\end{array} \right )
$$
where $V$ is a matrix V = [v1 ; v2].
The first column of $V$ as well as of the right-hand side are irrelevant to finding $z$ (though the entries should of course match). Using $V'$ for Vp = V(:, 2 : 3) we get
$$
V' =
\left ( \begin{array}{ccc}
bz+c & e-zd \\
fz+g & h+z
\end{array} \right )
=
\left ( \begin{array}{ccc}
b & -d \\
f & 1
\end{array} \right )
~ z + 
\left ( \begin{array}{ccc}
c & e \\
g & h
\end{array} \right ).
$$
This matrix equation represents four different equations for $z$ which may or may not have the same solution. If not, there is no general solution.
The four separate solutions can be found in Matlab using element-wise division:
(Vp - [c e ; g h]) ./ [b -d ; f 1]

A solution exists if the four elements of the value of this expression are all the same.
A: You can easily do this entirely symbolically in Matlab if your wish. Not with linsolve, but with solve:
syms a b c d e f g h z k
v1 = [a b*z e-z*d];
v2 = [e f*z+g h+z];
s = solve(v1==k*v2)

It's possible since you seem to be using an older version of Matlab, that you may need to to call solve using the old string format:
s = solve('a=k*e','b*z=k*(f*z+g)','e-z*d=k*(h+z)')

In both case you'll see that solve returns three outputs as there were three equations.
