Ok, I have been trying to use coeffs here is what I am currently have a problem with, although I have 5 symbolic variables, not all show up in every equation so when I try and gather coeffients I would like to be able to catch even the 0 values. heres what I have so far.
clcclear m= [2 -3 ; 3 -2];q = [ -1 -1]';xv = sym('x1');lm = length(m);yv = sym(zeros(1, lm))';zv = sym(zeros(1, lm))';for k=1:lmyv(k) = sym(sprintf('x%d', k+1));zv(k) = sym(sprintf('x%d', k+lm+1));endA = [-(m*yv+xv*q);m*yv+xv*q-zv; yv-zv;zv-yv];Aineq=zeros;temp = zeros;for i=1:length(A) temp=coeffs(A(i,:)) for j=1:length(temp) Aineq(i,j)=temp(j) endendAineq
the last nested for was my attempt to gather the coefficients. I but I cannot place them in the right way this way. Any suggestions? I have looked at ineval and feval but I do not see the how to use these tools
Oh this is what my output looks like A =
-2*x2+3*x3+x1 -3*x2+2*x3+x1 2*x2-3*x3-x1-x4 3*x2-2*x3-x1-x5 x2-x4 x3-x5 x4-x2 x5-x3 Aineq = 1 -2 3 0 1 -3 2 0 -1 2 -3 -1 -1 3 -2 -1 1 -1 0 0 1 -1 0 0 -1 1 0 0 -1 1 0 0 So this is where I am stuck at this point.
Best Answer