Plot fitted polynomial and all data points using


Problem:

A noise that grows louder over time is measured six times, and the following dataset is created (data in NoiseTime.txt and NoiseLoud.txt): 

Time (s)

1

1.3

...

5.6

6

Loudness (dB)

1.3

2.7

...

86

104

 Use MATLAB to perform the following tasks:

(Note: You will have to run this program more than once in order to complete it.)

a) Determine which type of function may provide the best fit by plotting the data on the following axes. Use the subplot command to include them in the same window (see problem c for plot arrangement).

X -axis

Y - axis

Function

Linear

Linear

Linear  y=mx+b

Logarithmic

Logarithmic

Power Y=bxm

Linear

Logarithmic

Exponential  y= bemx

 The best function is the one whose data points appear to be in a straight line. Decide upon the best function, and output your choice of function to the command window (linear, logarithmic, or exponential).

b) Use polyfit to find a polynomial that fits the data. Use the following table to choose the correct format for polyfit. Note: polynomial degree n=1 always when fitting a non-polynomial. The first element p(1) gives m, and the second element p(2) gives b. In order to plot on linear-linear axes, you will have to transform the constants back. Output the values of m and b, transformed to linear-linear axes (to 3 decimal places), to the command window (using fprintf).

Function

Polytfit form

Linear

P=polytfit(x,y,n)

Power

P=polyfit(log(x),log(y),1)

Exponential

P=polyfit(x,log(y),1)

c) Plot your fitted polynomial and all data points (using linear-linear axes) as a fourth subplot in the same window (as shown below). Use intervals of 0.1. Include a legend.

Subplot arrangement

Linear Data Plot  (1,1)

Power Transformed Data Plot (2, 1)

Exponential Transformed Data Plot (2, 1)

Fitted Function Plot (2, 2)

Additional information

This question to MATLAB software and discusses about application of MATLAB in mathematics to solve polynomials and to perform given tasks.  

Answer is in MATLAB format

Solution Preview :

Prepared by a verified Expert
MATLAB Programming: Plot fitted polynomial and all data points using
Reference No:- TGS01372476

Now Priced at $35 (50% Discount)

Recommended (94%)

Rated (4.6/5)