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

write three MATLAB functions involving the three forms of the equation of a line

ID: 2079510 • Letter: W

Question

write three MATLAB functions involving the three forms of the equation of a line

Write the following functions per the requirements listed: Slope-Intercept form of a linear equation y = mx + b where m = slope and b = y intercept Assume the function is called hw1_lin1(). The function you write will have three input parameters, m, b and an x_value and the function returns the y_value associated with the x_value. The function must include help comments that list what the inputs and outputs are as well as how to use the function. Point-slope form of a linear equation (y - y1) = m(x - x1)where m = slope and x1, y1 is the first point Assume the function is called hw1_lin2(). The function you write will have four input parameters, m, x1, y1 and an x_value and the function returns the y_value associated with the x_value. The function must include help comments that list what the inputs and outputs are as well as how to use the function. Standard form of a linear function Ax + By = C where A, B, C are constants Assume the function is called hw1_lin3(). The function you write will have four input parameters, A, B, C, and an x_value and the function returns the y_value associated with the x_value. The function must include help comments that list what the inputs and outputs are as well as how to use the function.

Explanation / Answer

hw1_ln1.m

function y = hw1_ln1(m,b,x_value)
%this function takes m,b,x and produces y = mx + b
y = (m*x_value)+b;
end

command window:

>> y = hw1_ln1(1,2,3)

y =

5

hw1_ln2.m

function y = hw1_ln2(m,x1,y1,x_value)
%this function takes m,b,x,y1,x1 and produces (y-y1) = m(x-x1);
y = (m*(x_value-x1))+y1;
end

command window output:

>> y = hw1_ln2(1,2,3,4)

y =

5

hw1_ln3.m

function y = hw1_ln3(A,B,C,x_value)
%this function takes m,b,x,y1,x1 and produces Ax + By = C;
y = (C-(A*x_value))/B;
end

command window output:

>> y = hw1_ln3(1,2,3,4)

y =

-0.500000000000000

>>