개발자 뺚
[Cody] Problem 44946. Solve a System of Linear Equations 본문
Example:
If a system of linear equations in x₁ and x₂ is:
2x₁ + x₂ = 2
x₁ - 4 x₂ = 3
Then the coefficient matrix (A) is:
2 1
1 -4
And the constant vector (b) is:
2
3
To solve this system, use mldivide ( \ ):
x = A\b
Problem:
Given a constant input angle θ (theta) in radians, create the coefficient matrix (A) and constant vector (b) to solve the given system of linear equations in x₁ and x₂.
cos(θ) x₁ + sin(θ) x₂ = 1
-sin(θ) x₁ + cos(θ) x₂ = 1
function x = solve_lin(theta)
a = [cos(theta), sin(theta); -sin(theta), cos(theta)];
b = [1; 1];
x = a \ b;
end
'Solution > MATLAB' 카테고리의 다른 글
[Cody] Problem 55220. Matrix Quadrants (0) | 2023.11.18 |
---|---|
[Cody] Problem 790. Cody Computer Part 5 - Guess the Name of Cody Computer (0) | 2023.10.13 |
[Cody]Problem 44947. Find the Oldest Person in a Room (0) | 2023.08.23 |
[Cody] Problem 44951. Verify Law of Large Numbers (11) | 2023.08.23 |
[Cody] Problem 44944. Convert from Fahrenheit to Celsius (0) | 2023.08.23 |