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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started