I have a given matrix of size NxN
(called M
),a vector of Nx1
(called V
), and two scalars (called a
and b
). I want to solve the linear system of equations for alpha. The dimensions are given as MATLAB reports them using the function size(-)
.
(M + a * b * 1) alpha == V
with 1 being a matrix of just 1s.
I figured the easiest way to do so would be
syms alpher;
Mprep = (M + a * b * ones(length(M),length(M)));
eqn = Mprep * alpher == V;
alpha = solve(eqn,alpher)
However, I get the error
Error using ==
Matrix dimensions must agree
I am not sure whether this error is due to the fact that Matlab does not know the proper size of alpher
or if I am just plain wrong in my approach. The error occurs in the second last line according to matlab.
What is the best way to solve this in MATLAB?
M = N
based on M being symmetric and thusones(length(M),length(M))
having the same dimensions as M itself. Additionally the error occurs in the second last line so any presumed error in a previous line is rather unlikely. (this was a response to a now deleted comment) – Sim