Posted By:
24 Mar, 2013 12:35 pm PDT

fmincon to solve linear set of equations in Matlab

I have 3 equations in x,y,z as follows:
x+3y-z = 5

I want to solve these equations using fmincon. How can I do it?

The solution of x,y,z should be
x= 6.8750
y= 0.6250
z= 3.7500


fmincon function solves an optimization problem, which minimizes a objective function subject to equality and inequality constraints In this case, we ll use only linear equality constraints, and a constant objective. Rest of the parameters wont be defined.

clear all
% x-y+z=10
% x+y+2z=15
% x+3y-z = 5
%to solve aboove set of equations
A = [1 -1 1;
    1 1 2;
    1 3 -1];
b = [10;15;5];

x0 =[1;1;1]; % initial guess
x_final = fmincon(@(x)5,x0,[],[],A,b);

Please watch the video and attached matlab file for details

Attachment: fmincon_linear.m
Was it useful?  

Please login to reply to this problem.