Write a MATLAB code for the following problem: Consider the equation of a plane
ID: 2081104 • Letter: W
Question
Write a MATLAB code for the following problem:
Consider the equation of a plane written as a_1 x+a_2 y+a_3 = z. Given three known points (x_1, y_1, z_1), (x_2, y_2, z_2), and (x_3, y_3, z_3), write the system of equations that determine a_1, a_2, and a_3. Write a plane function that returns the a, given any three points. Test your function by finding the equation of the plane passing through (1, 0, 0), (0, 1, 0), and (0, 0, 1). What are the values of z at (x, y) = (0, 0.5), (0.5, 0), (0.25, 0.25), and (0.5, 0.5)?Explanation / Answer
plane.m
function a = plane(s1,s2,s3)
A = [s1(1) s1(2) 1;s2(1) s2(2) 1;s3(1) s3(2) 1];
b = [s1(3);s2(3);s3(3)];
a = A;%gives inv(A)*b which is our solution
end
command window log:
>> clear all
>> ai = plane([1 0 0],[0 1 0],[0 0 1])
ai =
-1
-1
1
>> z = (ai(1)*(0))+(ai(2)*(0.5))+ai(3)
z =
0.500000000000000
>> z = (ai(1)*(0.5))+(ai(2)*(0))+ai(3)
z =
0.500000000000000
>> z = (ai(1)*(0.25))+(ai(2)*(0.25))+ai(3)
z =
0.500000000000000
>> z = (ai(1)*(0.5))+(ai(2)*(0.5))+ai(3)
z =
0
>>
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.