Question: Write a MATLAB program that accomplishes the following using vectorized code: a. Creates an x vector with elements from 1 to 10 in steps of
Write a MATLAB program that accomplishes the following using vectorized code:
a. Creates an x vector with elements from 1 to 10 in steps of 0.5,
b. Creates a y vector from the equation y = 2*x - 3,
c. Modifies the y vector by randomly adding or subtracting 0.7 to every element in the y vector,
d. Fits a straight line through the data points given by the x and modified y vectors using a least-squares approximation
e. Plots the (x, modified y) data points as blue stars and the straight line that was fit through these points, and f. Puts the straight line that was fit through the points as the title of the plot. (Dont forget to label the axes as well.)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
