Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please code in MATLAB and explain all steps Preamble This week's assignment focuses on curve fitting and on creating anonymous functions. Question 1 Part (a)

Please code in MATLAB and explain all steps

Preamble

This week's assignment focuses on curve fitting and on creating anonymous functions.

Question 1

Part (a)

Download the data file a3.mat (given below). This file contains data points (xi , yi) where xi is the i-th entry of array x and yi is the i-th entry of array y. It is known that the dependence between y and x is of the form equation (1) , y = (1 + a sin(2x))/ (b + cx^2) where a, b, c are unknown real constants. It is known that all data points (xi , yi) satisfy equation (1) up to small measurement errors. Clear the denominator in equation (1) and consider plugging in each data point. This leads to an overdetermined system of linear equations. Use Matlab's least-squares solver \ to find the least-squares approximate solution to this overdetermined system of linear equations. You must not use any for-loops or while-loops.

Part (b)

Use your answer to part (a) to find approximate values of a, b, c.

Part (c)

Plot the given data points (xi , yi) as circles. In the same figure, plot the fitting curve (1) with the values a, b, c determined in part (b), as a curve. You must not use any for-loops or while-loops. The plot of the fitting curve must be smooth. You should observe a good fit between the curve and the given data points.

Part (d)

Use an anonymous function (note that this is a special type of Matlab function) that accepts on input two positive integers m and n and it returns the m n matrix such that the entry in row i and column j is the number i j. Your function must not contain any for-loops or while-loops. Use the product of two suitable vectors.

Part (e)

Make a call to the function written in part (d) to create the 4 3 matrix with the given property. That is, the output of this function call should be (1 2 3; 2 4 6; 3 6 9 ;4 8 12)

note: data in given file a3.mat is: x=[2.466736149097078 1.809490404275269 -2.976828879329663 0.874552323557512 1.086516103267165 1.343473526817548 -2.577820772445449 -1.001086754505518 -1.700647985746729 1.000342401121538 -0.842930862682277 1.553237972147615 -2.090764858485738 -1.680985417390050 -2.272305098076415 -2.319657206456681 1.346461038200447 -0.101477063172149 -0.250698990818340 -2.275226008881366 1.265155588609469 0.110275657425330 -1.245238095538646 -0.433752300664733 -0.990959831240291 -2.620166541545791 -1.800419232231710 -2.383405325824172 -2.080461058587916 -1.800237371675486] y=[0.479106132638577 0.107769093783665 0.213664257708475 1.465117020988007 1.090982511101887 0.608201938234718 0.416169179928686 0.542636584491800 0.351417874518658 1.210958218288401 0.708123326683265 0.241675742216348 0.542347309187645 0.335432500884665 0.520232024868978 0.511419092120030 0.638912429246524 0.233132743244976 0.208228529210848 0.516676163868654 0.734694724105151 0.811399083975490 0.204750133837553 0.627464863149035 0.623418123527721 0.378643086563431 0.456422680652566 0.538750745819925 0.573623075985352 0.440436228760487]

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

Step: 3

blur-text-image

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

Spomenik Monument Database

Authors: Donald Niebyl, FUEL, Damon Murray, Stephen Sorrell

1st Edition

0995745536, 978-0995745537

More Books

Students also viewed these Databases questions

Question

Please help me evaluate this integral. 8 2 2 v - v

Answered: 1 week ago