Question
I need a write a general Matlab code about; function [U,c]=GE_m[A,b] n=length (b) for k=1:n-1 use while ( %locate row that contains 1st nonzero %
I need a write a general Matlab code about;
function [U,c]=GE_m[A,b]
n=length (b)
for k=1:n-1
use "while" ( %locate row that contains 1st nonzero
% among n^n possible entries)
If r=k, no need to swap ( % If r not= k, swap rth and kth row,
% then go them GE
If r>n disp ( If all possible pivot entries have zero, print out
" A is not invertible and the U and c returned are meaningless." Then quit out)
Command window:
1) >> A= [ 1 -1 2 -1
2 -2 3 -3
1 1 1 0
1 -1 4 3]
>> b= [ -8 -20 2 4]' transpose
>> [U,c]=GE_m(A,b)
>>x=ut_sys(U,c) check both funtion match
2) >> A=[1 1 1
2 2 1
1 1 2]
>> b= [4 6 6]' transpose
>> [U,c]=GE_m(A,b)
should get U= [ 1 1 1
0 0 -1
0 0 1] and c=[ 4, -2, 2]' transpose.
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