0

I am trying to plot this system:

 x1   - x2 + 3x3   = 8
 2x1  - x2 + 4x3  = 11
 - x1 + 2x2 -4x3 = -11

I tried with ezsurf and meshgrid, but I wasn't able to do it.

clc
clear all
close all
A = [1 -1 3; 2 -1 4; -1 2 -4];
B = [8 11 -11]';
C = [A B];
R = rref(C);
% R =
%     1     0     0     1
%     0     1     0    -1
%     0     0     1     2

D = R(:,4); % salvo la 4 colonna che contiene le soluzioni

disp('Le soluzioni del sistema proposto sono:');
disp(D);

figure(1);
hold on
grid on
syms x y z

eq = x + y + 3*z - 8;
Z = solve(eq,z)
ezsurf('8/3 - y/3 - x/3');

scatter3(D(1),D(2),D(3));

How can I plot this system of equations?

HebeleHododo
  • 3,620
  • 1
  • 29
  • 38

1 Answers1

5

Maybe I'm missing something, but you have 3 unknown x1, x2 and x3 for 3 equations, therefore there is a unique solution (provided the determinant of the matrix is not zero):

>> A = [1 -1 3; 2 -1 4; -1 2 -4];
>> B = [8 11 -11]';
>> x = A\B
x =

   1
  -1
   2

So there is nothing to plot other than a single point?

am304
  • 13,758
  • 2
  • 22
  • 40