Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

% Function Name: plotSystem3D % Inputs (3): - (double) Vector of coeffecients of

ID: 3539751 • Letter: #

Question

% Function Name: plotSystem3D

% Inputs (3): - (double) Vector of coeffecients of first equation

% (double) Vector of coeffecients of second equation

% (double) Vector of coeffecients of third equation

% Outputs (3): - (double) x value of the solution

% (double) y value of the solution

% (double) z value of the solution

%

% Output Plot - A plot of the solution plotted as a red circle

%

% Function Description:

% Write a function, plotSystem3D that solves a system of linear

% equations and plots the solution.

% Your function will have three inputs :

%

% - A vector consisting of the coefficients of the first linear equation

% of the form Ax+By+Cz=D, which would be [A B C D].

% - Another vector consisting of the coefficients of a second line

% equation, with the same form as the first input.

% - Another vector consisting of the coefficients of a third line

% equation, with the same form as the first input

%

% Your function should have three outputs: the x, y, and z value of the

% solution. Your function will also plot the solution plotted as a RED

% CIRCLE.

%

% Hints:

% - You will find the '' operator useful when solving the system.

% - Because you will have have an x, y, and z value, you NEED to use the

% plot3 function instead of plot. plot3 works the same way, but allows

% you to pass in three values (an x, y, and z).

%

% Test Cases:

%

% [x y z] = plotSystem3D([1 -3 3 -4], [2 3 -1 15], [4 -3 -1 19]);

% => x = 5, y = 1, z = -2

% => plot looks like test_case1_plot.fig

%

% [x y z] = plotSystem3D([4 2 -2 10], [2 8 4 32], [30 12 -4 24]);

% => x = -2, y = 6, z = -3

% => plot looks like test_case2_plot.fig

Explanation / Answer

% I have used the default formatting for output as you have not posted the output figures

% please post a pcture of your test output if you needed something different


function [x,y,z]=plotSystem3D(a,b,c)

A=[ a(1:3);b(1:3);c(1:3)];

vals=[ a(4); b(4); c(4) ];

ans=A als;

x=ans(1);

y=ans(2);

z=ans(3);

labels = cellstr( strcat('(',num2str(x),',',num2str(y),',',num2str(z),',',')') );


plot3(x,y,z,'ro');

grid on;

text(x,y,z, labels, 'VerticalAlignment','bottom', 'HorizontalAlignment','right');

end