Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

How to write this matlab function? In many situations, functions can be approximated as sums of sine and cosine functions. in this question, you will

How to write this matlab function? image text in transcribed
In many situations, functions can be approximated as sums of sine and cosine functions. in this question, you will approximate functions as sums of sine and cosine functions using least-squares linear regression. Given x- and y-data, you will fit a function of the form: f (x) = k + sigma^n_i = 1 a_i sin (ix) + sigma^n_i = 1 b_i cos (ix) where n is an integer that is greater than zero, and where tin* coefficients to fit are k, a_i, i = {1, 2, ellipsis, n}, and b_i, i = {1, 2, ellipsis, n}. Write a function with the following header: function [k, a, b] = my regression_sincos(x_data, y_data, n) where: x data and y data are two m times 1 arrays of class double that represent two-dimensional data. in other words, those column vectors represent a set of points of coordinates (x data (i), y_data (i)), i = {1, 2, ellipsis, m}. You can assume that, m > 1, and that all elements of x data and y data are different from NaN. Inf. and -Inf. n is a scalar of class double that represents n in liquation 1. You can assume that n is an integer such that n > theta. k is a scalar of class double that represents k in Equation 4. a and b are n times 1 arrays of class double such that a (i) represents a_i in Equation 1 and b (i) represents b_i in Equation 4. k, a, and b represent the coefficients of Equation 4, fitted to the x- and y-data represented by x data and y_data (respectively), using least-squares linear regression

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

Contemporary Issues In Database Design And Information Systems Development

Authors: Keng Siau

1st Edition

1599042894, 978-1599042893

More Books

Students also viewed these Databases questions