function F = comp(x)
F(1) = (x(1)+x(2)-x(6))*(2*x(1)+x(2)+x(3)+x(4))^2 - 2.937*10^5*(100-x(1)-x(3)+x(5)-x(6))*(1467-4*x(1)-3*x(2)-x(3)-x(4)+2*x(6))^4;
F(2) = (x(1)+x(2)-x(6))*(2*x(1)+x(2)+x(3)+x(4)) - 1.046*10^7*(100-x(2)+x(3)-x(4)-2*x(5)+2*x(6))*(1467-4*x(1)-3*x(2)-x(3)-x(4)+2*x(6))^3;
F(3) = (100-x(2)+x(3)-x(4)-2*x(5)+2*x(6))*(2*x(1)+x(2)+x(3)+x(4)) - 0.02808*(100-x(1)-x(3)+x(5)-x(6))*(1467-4*x(1)-3*x(2)-x(3)-x(4)+2*x(6));
F(4) = (2*x(1)+x(2)+x(3)+x(4)) - 5.555*10^5*(100-x(2)+x(3)-x(4)-2*x(5)+2*x(6))*(1467-4*x(1)-3*x(2)-x(3)-x(4)+2*x(6));
F(5) = (100-x(1)-x(3)+x(5)-x(6)) - 1.978*10^6*(100-x(2)+x(3)-x(4)-2*x(5)+2*x(6))^2;
F(6) = ((1467-4*x(1)-3*x(2)-x(3)-x(4)+2*x(6))^2)*(100-x(2)+x(3)-x(4)-2*x(5)+2*x(6))^2 - 1.166*10^(-9)*(x(1)+x(2)-x(6))*(100-x(1)-x(3)+x(5)-x(6));
end
function chem
fun = @comp;
x0 = [10,10,10,10,10,10];
x= fsolve(fun,x0)
CO = 100-x(2)+x(3)-x(4)-2*x(5)+2*x(6)
CO2 = 100-x(1)-x(3)+x(5)-x(6)
H2 = 1467-4*x(1)-3*x(2)-x(3)-x(4)+2*x(6)
CH4 = x(1)+x(2)-x(6)
H2O = 2*x(1)+x(2)+x(3)+x(4)
C = x(4)+x(5)
end
실행하면
'x'은(는) 인식할 수 없는 함수 또는 변수입니다. 가 뜨면서 실행이 안됩니다. 방정식 풀고 싶은데 수정 가능할까요?