Search code examples
matlabnonlinear-functionsquadratic-programming

How do you plot nonlinear quadratic system?


Consider the following system of two nonlinear (quadratic) equations with š‘Ž = 0.400256 and š‘ = 0.916403.

āˆ’š‘„ + š‘Žš‘„ āˆ’ š‘š‘¦ + š‘š‘„^2 = 0

āˆ’š‘¦ + š‘š‘„ + š‘Žš‘¦ āˆ’ š‘Žš‘„^2 = 0

Plot the two implicit equations and observe that there are two solutions: one at the origin and the other one close to (1.3, 0.8).

Here is what my code looks like so far:

a=0.400256;
b=0.916403;
f = @(x) [-x(1) + a*x(1) - b*x(2) + b*x(1)^2];
f2 = @(x) [-x(2) + b*x(1) + a*x(2) - a*x(1)^2];
ezplot('f',[-10 10 -10 10]); hold on;
ezplot('f2',[-10 10 -10 10]);
grid

Solution

  • You were on the right track, but didn't defined the functions properly.

    a=0.400256;
    b=0.916403;
    f1 = @(x,y) -x + a*x - b*y + b*x.^2;
    f2 = @(x,y) -y + b*x + a*y - a*x.^2;
    ezplot(f1);
    hold on
    ezplot(f2);