Question

Write a Matlab function that will return the row canonical form for any given row echelon...

Write a Matlab function that will return the row canonical form for any given row echelon matrix; your function should return an appropriate error if the input matrix is NOT in echelon form.

Homework Answers

Answer #1

function [ val mat ] = simplex_min(Q,R )

Q =[7 9 31 1 6 1 0; 4 3 8 1 7 0 10; 9 9 8 1 2 7 1]
R = [0 0 0]
[ na ma] = size(Q);
[ nc mc] = size(R);


if nc ~= 1
disp(' check the given objective ')
return
end


if ma-1 ~= mc
disp('Check the given objective function')
return
end


P = [ Q(:,1:ma-1) eye(na) Q(:,ma) ];
P(na+1,:) = zeros(1,na+ma);
P(na+1,1:mc) = -R;% Indicator row.


while sum(P(na+1,1:na+ma-1) > zeros(1,na+ma-1)) ~= 0

xw = P(1:na , 1:na + ma - 1);
[ v1 i1 ] = max(xw);
[ v2 j ] = max(v1);
i = i1(1,j);
Y = P(1:na,na+ma)./P(1:na,j);
a1 = sign(Y);
a1 = a1 + ones(na,1);
y1 = Y.*a1/2;
[ v3 i ] = min(y1);% finding lowest non -ve no
if v3 == 0
ys = sort(y1);
k = 1;
while ys(k,1) <= 0
k = k + 1;
end
b = ys(k,1);
[ i j1 ] = find( y1 == b );
end
P = elimination(P,i,j);
  
  
ele = find(sign(P(na+1,1:na+ma-1))== -1);
[ ne me ] = size(ele);
if me == 0
break
else
j = ele(1,1);% fixing pivot column
Y = P(1:na,na+ma)./P(1:na,j);
a1 = sign(Y);
a1 = a1 + ones(na,1);
y1 = Y.*a1/2;
[ v3 i ] = min(y1);
if v3 == 0
ys = sort(y1);
k = 1;
while ys(k,1) <= 0
k = k + 1;
end
b = ys(k,1);
[ i j1 ] = find( y1 == b );
P = elimination(X,i,j);
end
end
  
for k = 1:na+ma-1
un = sign(P(:,k));
if un == - ones(na+1,1)
disp(' It is not bounded')
return
end
end
end


opt = P( na+1, ma+na);
sol = P(1:na , 1:ma-1);
for k = 1: ma-1

t = roots( [sol(:,k);0] );
[ nt mt ] = size(t);
if t == zeros(nt,1)
mat(1,k) = X(na - nt +1, na+ma);
else
mat(1,k) = 0;
end
end
disp('Co-efficient matrix ')
mat
disp(' optimum value ')
opt

function P = elimination(P,i,j)



[ nX mX ] = size( P);
a = P(i,j);
P(i,:) = P(i,:)/a;
for k = 1:nX
if k == i
continue
end
P(k,:) = P(k,:) - P(i,:)*P(k,j);
end

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
3. Write the matrix in row-echelon form: 1 2 -1 3 3 7 -5 14 -2...
3. Write the matrix in row-echelon form: 1 2 -1 3 3 7 -5 14 -2 -1 -3 8
If the reduced row echelon form of an m*n matrix A has a pivot in every...
If the reduced row echelon form of an m*n matrix A has a pivot in every row, explain why the columns of A must span R^m
Find the reduced row echelon form of the following matrices. Interpret your result by giving the...
Find the reduced row echelon form of the following matrices. Interpret your result by giving the solutions of the systems whose augmented matrix is the one given. [ 0 4 7 0 2 1 0 0 0 3 1 -4 ]
T12. Suppose that A is a square matrix. Using the definition of reduced row-echelon form (Definition...
T12. Suppose that A is a square matrix. Using the definition of reduced row-echelon form (Definition RREF) carefully, give a proof of the following equivalence: Every column of A is a pivot column if and only if A is the identity matrix (Definition IM). http://linear.ups.edu/html/section-NM.html
Solve and explain the process of solving the following system with matrix reduced row-echelon form. Last,...
Solve and explain the process of solving the following system with matrix reduced row-echelon form. Last, explain your results for the following problem: 3x – 4y + 4z =7 x – y – 2z = 2 2x – 3y + 6z = 5
Find the complete solution by reducing the augmented matrix to row-echelon form and show all the...
Find the complete solution by reducing the augmented matrix to row-echelon form and show all the matrices, using arrows to indicate the order x-2y+z= -3 2x-7y+8z= -12 3x-2y-5z= -1
Solve the following systems by forming the augmented matrix and reducing to reduced row echelon form....
Solve the following systems by forming the augmented matrix and reducing to reduced row echelon form. In each case decide whether the system has a unique solution, infinitely many solutions or no solution. Show pivots in squares. Describe the solution set. -3x1+x2-x3=10 x2+4X3=12 -3x1+2x2+3x3=11
Consider the following matrix A and its reduced row-echelon form: Find the dimensions of row(A), null(A),...
Consider the following matrix A and its reduced row-echelon form: Find the dimensions of row(A), null(A), and col(A), and give a basis for each of them. A= ( < 0, 0, 0,1 > , < 0, 0, 0, 3 >, < 3, 0, -3, -2> , < 6, 0, -6, -9 > , < -3, -5, 13 , -2 >, <-6, -10, 26, -8 > ) rref = ( < 1, 0 ,0, 0 >, < 3, 0, 0, 0...
Write a MATLAB function that is called sphereva which can do the following: a- Receive one...
Write a MATLAB function that is called sphereva which can do the following: a- Receive one input argument, which represent the radius of a sphere. The input argument can either be a scaler, vector or matrix variable. b- Return the volume and surface area of the sphere(s) for the passed argument.
Part 2: Solve the following problems in MATLAB 1. Fill in the function E = myElim(A,...
Part 2: Solve the following problems in MATLAB 1. Fill in the function E = myElim(A, r_entry, r_pivot, c) to create an m by m elimination matrix ??. Remember that an elimination matrix looks like an identity matrix with one extra entry of ?? in row r_entry and column r_pivot. 2. Fill in the function M = myMult(A, c_pivot) to create an m by m multiplier matrix ??. Remember that a multiplier matrix looks like an identity matrix with the...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT