MATLAB: Create graph of a small rectangular box that represents a car that moves
ID: 3831492 • Letter: M
Question
MATLAB: Create graph of a small rectangular box that represents a car that moves on an inverted Y shaped path. The car starts from the top and moves to the right or left of the Y path based on a user input to the program (use an input function). Have the car repeat the motion 3 times using a 'while loop'. The car should increase its speed based on the equation: speed = 3i. where i is the repetition number. The value of the speed should be calculated in a subroutine within the MATLAB program and sent back to the main program The input to the subroutine should be the value of i and the output of the subroutine to the main program is speed. The while loop should terminate once the speed reaches a value >= 12 Create a plot of y = x^2 + 3x + 3: for: 4 >= x >= -4 and determine the roots of the equation using goal seek Given: Plot and determine the equation of the curve and corresponding R^2 value that best represents the data using the trend line feature by checking all the curveExplanation / Answer
Q2) The Equation for creating a plot is y = x2 + 3x+3 is determined using goal seek method.
Firstly we need to find the quadratic equation for this plot using the following equation: ax2 + bx + c = 0.
The values of a=1, b=3 and c=3.
Its time to determine the value of D which calculates the interception for each equation.
D = b2- 4ac = (3)2 - 4 * 1 * 3 = 9 -12= -3
so, The value of D= -3
Next step is to calculate the x coordinates.
x = -b + D / 2a
=> x = -3 + 3 / 2(1)
=> -3 + 1.73 / 2
=> -1.268 / 2
=> x = -0.634
(or)
x = -b - D / 2a
=> x = -3 - 3 / 2(1)
=> -3 - 1.73 / 2
=> -4.732 / 2
=> x = -2.366
So, Finally we get the both values for x is -0.634 and -2.366
Last step is to use the goal seek feature using what if analysis in the excel sheet under the data tab;
Basically it solves the situation for the value x=-2.366 and excel simultaneously finds the solution for the x value.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.