Solving a system of Linear Equations with constraints. Using Symbolic math.

6 views (last 30 days)
I have the following system of equations with a constraint:
n equations with n unknowns
Here are all known. (Its a known n*n matrix of values).
The following is my try at a solution. How can I correct it to get the 's
p_ij = [0.5, 0.5; 0.2, 0.8];
length_pi_i = size(p_ij);
length_pi_i = length_pi_i(1);
syms pi [1 length(p_ij)]
assume(sum(pi) == 1);
zero_vector = zeros(length(pi), 1);
eqn = (pi' - (pi * p_ij)' == zero_vector);
M = solve(eqn, pi);
disp(M);

Answers (1)

Tanmay Das
Tanmay Das on 30 Dec 2021
Hi,
I tried reproducing your steps in MATLAB R2021b release and received the following output in the command window:
pi1: 2/7
pi2: 5/7
I tried verifying the answer manually and the answer seems correct to me.
In case you want to learn more about symbolic functions, you may look into 'syms','assume', and 'solve' function documentation.

Products


Release

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!