f=@(x) 2-2*x(1)-x(2) %%Check admissibility
for j=1:size(sol,1); z=sol(j,1:2) if f(z)>=-1 fprintf('Admissible') check(j)=0; else fprintf('Not admissable') check(j)=1; end endfor j=1:size(sol,1) %%Remove non admissible rows from solutions
if check(j)==1 sol(j,:)=[]; end end
Hi, I am trying to check if the variable value stored in the first two columns of the matrix sol =
[ 0, 0, 0, 0, 0][ 1, 0, -1, 0, 0][ 0, 2, 4, 0, -10][ 6, -2, 0, 10, 0][ 0, 4, 0, -8, -12][ -2, 6, -16, -30, 0]
satisfy the inequality on f, and, if not, delete the relative row.
I've written the code above, but the problem is that when one row is canceled the dimensionality of the matrix is altered and everything goes awry (unless the row to be deleted is the last one).
How can I fix this?
Best Answer