Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Lab 8 Assignment Done on MatLab Due on 04/02 at the beginning of lab. Submit your m-file, diary showing a successful run, and figure. 1)

Lab 8 Assignment

Done on MatLab

Due on 04/02 at the beginning of lab.

Submit your m-file, diary showing a successful run, and figure.

1) Download Lab 8 data2.mat to your current directory from our shared folder. Note: The variable loaded from here is called data. Load the file in your workspacefrom the command window to confirm. After loading Lab 8 data2 in your code, you must call on the variable in your code by data

2) Write an m-file to load data from Lab 8 data2.mat and compute the least squares approximation for the data. This should be the best fit parabola The function will have no input and no output.

Your function should work for any.matfile containing an m 2 matrix, where m is a positive integer.

The function should plot the data points and the approximating parabola in one figure with a legend.

The function should print the equation of the parabola of best fit.

See the in-class exercise answer for plot and print formatting.

Note:

The equation of a parabola is

y = Ct^2 + Dt + E

This is the Lab hint

function lsaparabola

% Load data. The data has the to be in the same directory or sub-directory

% as this function. Its file name should go in filename.mat.

% Retrieve the size of the data.

% The data is ordered pairs (t,y) with the first column being the t values,

% and the second column being the y values.

% Form coefficient matrix A and the right hand side b in Ax = b.

% We are fitting the parabola y = Ct^2 + Dt + E. Given data points (t,y),

% we want to find the C, D, E that form the parabola that best fits this

% data.

Form A

Form b

% Find the least squares solution x. This found from the projection of b

% onto the column space of A.

% Retrieve the parameters C, D, E.

C = x(1); D = x(2); E = x(3); % actual MATLAB code

% Form the parabola y = Ct^2 + Dt + E to plot.

Form t as a linearly spaced vector between the

minimum and maximum t data values.

Form y, the parabola.

% Plot the data and the parabola of best fit on the same axes with

% appropriate formatting.

% Print the result.

% %f, as opposed to %d, prints the result as a floating point with

% out the scientific notation.

end

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Databases And Information Systems 23rd European Conference Adbis 2019 Bled Slovenia September 8 11 2019 Proceedings Lncs 11695

Authors: Tatjana Welzer ,Johann Eder ,Vili Podgorelec ,Aida Kamisalic Latific

1st Edition

3030287297, 978-3030287290

More Books

Students also viewed these Databases questions

Question

=+applying to all or most employers and employees?

Answered: 1 week ago

Question

=+associated with political parties and if so, which ones? Are

Answered: 1 week ago