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
Solution Stats
Problem Comments
- 
		7 Comments
		    Show
		    4 older comments
		  
		  
		Vijay Anand Ramachandran
    	on 26 Apr 2020
	
	
  	The problem statement clearly states to use mldivide (\)
How can the leading solution be cos(theta)+sin(theta)*[-1;1]
		Sindhuja Thonti
    	on 20 Jul 2020
	
	
  	My code is working perfectly on my desktop Matlab version, but here it's not accepting and displaying as incorrect..anyone help me out!
		goc3
    	on 29 Sep 2020
	
	
  	The syms function is in a toolbox—Cody does not currently support any toolbox functions.
		yuxiang
    	on 10 Sep 2022
	
	
  	what is coefficient matrix?I can't understand the meaning of the question
		poonam k
    	on 23 Jun 2024
	
	
  	simple problem
		未来
    	on 30 Dec 2024
	
	
  	好!
		Caleb
    	on 31 Jul 2025
	
	
  	Good intro to initializing a matrix in MATLAB
Solution Comments
Show commentsProblem Recent Solvers13659
Suggested Problems
- 
         
         838 Solvers 
- 
         ベクトル [1 2 3 4 5 6 7 8 9 10] の作成 580 Solvers 
- 
         Mersenne Primes vs. All Primes 736 Solvers 
- 
         
         898 Solvers 
- 
         
         604 Solvers 
More from this Author13
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!