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

HW2_7 Write a MATLAB function that plots a line segment & its midpoint. The func

ID: 440256 • Letter: H

Question

HW2_7 Write a MATLAB function that plots a line segment & its midpoint. The function should take as input m & b (for the line) and two x values for the endpoints of the line. The program should plot the line as a solid black line, and the midpoint as a red circle. The output of the program should be the x,y coordinates of he midpoint. For example, to find the midpoint of y = 2x + 1 on 0 ge x le 10, type this command into the Command Window: Submit your function M-file, a script M-file with this command in it, and the jpg that is created when running the script M-file HW2_8 (Continuation of HW2 7) Write a MATLAB function that does the same task as in HW2_7, but has the input and output contained in arrays. For example, to get the same results as in HW27, type Note that the first input contains the slope (m) and intercept (b) in one array, and the second input contains the lower and upper endpoints in a separate array. The output contains the midpoint, both the x and y locations together, also in an array. Submit your function M-file, a script M-file with this command in it except use different input values, and the jpg that is created when running the script M-file.

Explanation / Answer

This will help you :) http://www.mathworks.in/help/matlab/ref/plot.html http://www.mathworks.in/help/curvefit/fnplt.html Cheers! Please rate :)