Cramer's Rule Homework Help
显示 更早的评论
Hello,
I am having a lot of trouble with this homework because I am new to matlab. Please help!
Question:
Create a MATLAB script that will read in system of linear equations (SOLE) stored in an excel file (the format will be described in more detail below) and solve for all variables using Cramer's rule. You may assume that you will always be given the same number of equations as there are number of variables, i.e. if there are three variables (x, y, z) then there will be three equations. However, your code should be able to work for an arbitrary size system of linear equations. That means you cannot assume and hardcode the size of the SOLE in your code. Use the size function in Matlab.
I am not looking for the answer, but help and hints on how to go about doing this. This is what I have based on some of my previous knowledge and what I have seen online.
data = xlsread('sole_ex1.xlsx');
x = cramer(A,b);
if det(A) == 0; error('Matrix is invalid'); end
[z,z] = size(A); for g = 1:z;
B = A;
B (:,g) = b;
x(g) = det(B)/det(A);
end
x = x';
Thank You, Ryan Albawab
1 个评论
Rakib Seemanto
2020-11-1
how to find the value of x and y by using Cramer’s rule from these equations:
𝑎𝑥+𝑏𝑦=𝑐 and 𝑑𝑥+𝑒𝑦=𝑓 ???
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!