Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

C.

Solving systems of linear equations


1. If you are tasked to find the solution of two simultaneous equations, e.g.

𝑥 + 2𝑦 = 4
2𝑥 − 𝑦 = 3
Two approaches can be done:
Approach 1: Matrix method

>> a = [ 1 2; 2 -1]; <Enter>


>> b = [4; 3]; <Enter>
>> x = a\b <Enter>

Approach 2: Built-in solve function


>>syms x y; [x,y] = solve(x+2*y-4, 2*x-y-3) <Enter>
>> whos <Enter>
>> x = double(x), y = double(y) <Enter>
>> whos <Enter>

You might also like