Solving system of Non-linear Equations graphically
Afficher commentaires plus anciens
Problem Statement: I want to solve a set of equations graphically by plotting their graphs and looking at the interesection. I know how to solve a linear system of equations in 2D, like this.
%Simulataneous Equations
%3x1+2x2 =10
% 2x1 - x2 =2
%Graphical Solution
x= 0:0.1:10;
x1 = (1/3).*(18-2.*x);
x2= -2 + 2.*x;
plot(x,x1,'r')
hold on
plot (x,x2,'b');
grid on
xlabel('x1')
ylabel('x2')
Now I want to do a similar thing but for a set of equations with two variables instead of one. The equations are
I want them to plot like I could for above example and see their intersection. I know second equation is just a constant and hence i expected a plane passing through the value 5.
My attempt:
% Making an vector for input variable
x1_1= linspace(0,20);
y1_1=ones(1,100)*5;
%making a grid
[x1_1,y1_1] = meshgrid(x1_1,y1_1);
%The third equation of the set
z1_1= (1 + x1_1.*y1_1)./(x1_1+x1_1^2);
%making a vector for other plot
y1_2=ones(1,100)*5;
z1_2 = linspace(0,20);
%making a grid
[y1_2,z1_2] = meshgrid(y1_2,z1_2);
x1_2= 1+y1_2-z1_2;
% Plotting for 3D graph.
surf(x1_1,y1_1,z1_1);
hold on
surf(x1_2,y1_2,z1_2);
I did not do for the third equation but all I get are two lines instead of two planes intersecting at some point. If any help or a small hint with the code can be provided, i would be thankful to you.
Thank you.
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Surface and Mesh Plots dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
