Write a function that will take in a simplex tableau and an associated basis, and return the initial feasible

Please help me with this question.. I have attached the.m file of my code.
Also, here is the sample tableau and basis
tableau = [0 -2 0 0 0;
1 -1 1 0 4;
-1 1 0 1 1]
basis = [3; 4]

9 Comments

I don't see an attached file. You might want to edit your question and try to attach it again.
The attachement is missing and the question is not clear.
I assume you're a french speaker, in which case tableau probably mean array, but I've no idea what you mean by the initial feasible.
so its not exactly uploading but.. here's the code.
function [x, z] = readSolution(tableau, basis)
tableau = tableau(:,[2:end]);
basis = tableau(:,end);
x = linsolve(tableau, basis)
z = tableau(1,:)
end
Actually, tableau is the phrase usually used for linear programming. At least it was for me, and my command of French is limited to what I learned (poorly at that) in the 6th grade.
or how about this, im not understanding the error that matlab is giving me..
Attempted to access basis(3); index out of bounds because numel(basis)=2.
Error in readSolution (line 6) x(basis(i+1),1)=sol(i,1);
numel means number of elements, so you are trying to access basis(3) which is impossible because basis only has 2 elements..
the error occurs at line 6, when you itterate the basis index
i do not know the whole code, so i can't know what you want to do exactly, but:
"basis(i+1)" cannot be higher than "basis(2)" because you only have 2 elements in the basis vector.. Therefore the only possible values of "i" is 0 and 1.
if you want to iterate i further than 1 in the code you gave your basis vector must be longer.
If you don't want your basis vector to be longer than 2 you have to think about the logic in your iterations.

Sign in to comment.

Answers (0)

Categories

Find more on Linear Algebra in Help Center and File Exchange

Asked:

LG
on 30 Apr 2015

Edited:

on 30 Apr 2015

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!