% Himmelblau & Riggs 7th ed, Workbook problem 7.4 % example of solution of simultaneous algebraic equations % % from compenent balances % 0.8 F - 0.8 wBF - 0.109 W = 350 % 0.2 F - 0.2 wBF - 0.217 W = 0 % wBF - 0.674 W = 0 % % write in the matrix form % a*x = b % a is coefficient matrix % x is unknown vector = [F; wBF; W] (column vector) % b is constant vector (column vector) % when entering matrix row elements, can separate with space or comma % when starting new matrix row, can terminate previous row with % new line (see entry of a below) or semicolon (see entry of b below) % semicolon at end of line of code suppresses screen echo of result a = [0.8 -0.8 -0.109 0.2 -0.2 -0.217 0 1 -0.674]; b = [350; 0; 0] fprintf('solution using x = inv(a)*b') x = inv(a)*b fprintf('check result') bp = a*x % alternatively use backslash operator % which also estimates answer with overdetermined systems fprintf('solution using x = a\\b') x = a\b % note backslash