Question
MATLAB Need help writing MatLab Program for Cramer's Rule. (REQUIREMENTS BELOW) For this lab the function will solve a 3x3 and a 4x4 examples from
MATLAB
Need help writing MatLab Program for Cramer's Rule. (REQUIREMENTS BELOW)
For this lab the function will solve a 3x3 and a 4x4 examples from the Cramers Rule Theory Document. The ULTIMATE purpose is to write this embedded function so that it can work for any system of simultaneous equations. This requires a use of matrix and vectors of size n. The second purpose is to use the Matlab functions to read and write to excel files.
Read Cramers Rule.docx to understand the concept. Run the Excel_Arrays.m file using the Excel and Matlab.xlsx file. This program shows how to read and write Excel files from Matlab.
Requirements:
1. Write a main Function that loops.
2. Have the user choose to solve a 3 by 3 or a 4 by 4 systems of equations.
3. Then the program should read the data from the appropriate sheet in the given Excel File 3Eq-4Eq.xlsx. The file has a Matrix for the Coefficients and a Vector for the Constants. These items are then passed to an embedded function to solve by Cramers Rule. See the Program Excel_Arrays.m and the Excel and Matlab.xlsx files to learn how to read and write from Excel to Matlab.
4. Write an embedded function to solve by Cramers Rule with 3 parameters:
a. Coefficient Matrix (CO)
b. Constant Vector (K)
c. Dimension of the Coefficient Matrix (n)
5. This function outputs a Vector of n unknowns.
6. This function should be built around a for loop driven by n the number of equations/unknowns.
a. For each cycle or pass of the loop this function will create the nth variables Matrix such as Mx above from the Coefficient Matrix and Constant Vector.
b. In this process the nth answer is found by the Determinant Ratio and is placed in the answer in the nth cell of the Answer Vector.
c. Finally when the loop completes output the Answer Vector to the calling Function.
7. Then the main function wil write the Answer Vector into the correct Range of the correct sheets of the Excel File 3Eq-4Eq.xlsx.
THIS STRUCTURE IS REQUIRED SO THAT OTHER SIMULTANEOUS EQUATION SOLUTIONS CAN BE DONE EASILY. You are building a general Cramer Rule Function that can solve for n Equations and n Unknowns. THIS FUNCTION WILL BE COPIED AS IS INTO THE NEXT LAB TO SOLVE A PRACTICAL PROBLEM.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started