2 and 3). nge Problem Create a MAT function M-file called my matrix solver to so
ID: 3406078 • Letter: 2
Question
2 and 3). nge Problem Create a MAT function M-file called my matrix solver to solve a sys- tem of linear equations, using nested for loops instead of MATLAB's built-in operators or functions. Your function should accept a coefficient matrix and a result matrix, and should return the values of the variables. For example, if you wish to solve the following matrix equation for X AX your function should accept A d Bas input, and return x as the result. Test your function with the system of equations from the previous problem.Explanation / Answer
function x=my_matrix_solver(A,B)
A_inv=inv(A);
x=zeros(length(B),1);
for i=1:length(B)
for j=1:length(B)
x(i,1)=x(i,1)+A(i,j)*B(j);
end
end
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.