Answered step by step
Verified Expert Solution
Question
1 Approved Answer
The MATLAB code shown below generates a plot of the line y=3x2+2x+5 in a new figure window. Copy the code below to a script m-file
The MATLAB code shown below generates a plot of the line y=3x2+2x+5 in a new figure window. Copy the code below to a script m-file and add code to it to wait for the user to mouse-click somewhere within the figure axes. After clicking, display a new title on the plot which indicates whether they clicked above the line, or below the line. You will need to use the waitforbuttonpress and get(gca, 'CurrentPoint') expressions. (50 Points) clear; clc; \% Clear all variables and CMD window x=10:10;% Define the 21-point x-range to evaluate (and plot) y= polyval (coeff, x ); % Compute the 21y-values of the line figure(2); clf; % Open figure 2 and clear the figure (clf) plot (x,y); grid on; \% Plot the line and add a grid title('Click anywhere on the Axes'); % Display initial instructions to the user Your script only needs to run once; you do not need to use a while-loop to repeatedly look for mouse clicks. Furthermore, you can assume the user will always click a mouse button on the figure; you do not need to check for keyboard button presses. Hints: recall that the mouse clicks values are stored as a 23 array. Evaluate the equation of your line at your mouse-click x-value (try polyval); if this y-value is less than your mouse-y, then the click was above the line
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