You are on page 1of 1

Assignment 1

1. Use MATLAB function polyfit to fit the given data.


a. Generate the data with the following function calls:
x=[1:100];
y=sin(0.1*x);
n=rand(1,100)*0.3; % additive noise component
y=y+n; % noise distorted signal
b. Fit the data with polynomial function polyfit.
c. Plot the fitted curve using functions polyval and plot
2. Change the order of the polynomial function to find the best fit.
3. Write a function to complete the following tasks:
a. Generate a one-dimensional Gaussian data using mean 0 and variance 10.
b. Randomly sample 20 samples from the Gaussian function and compute the
mean and variance.
c. Repeat step b 20 times and calculate the average mean and variance.
d. Print the differences to the true mean and variance.

You might also like