Perform a least squares polynomial fit

Assignment Help MATLAB Programming
Reference no: EM131044448

ASSIGNMENT

1) You can ask questions in the Discussion Board on Moodle

2) Hints and additional instructions are provided as comments in the assignment template M-Files

3) Hints may also be provided during lectures

4) The questions have been split into sub-questions. It is important to understand how each sub- question contributes to the whole, but each sub-question is effectively a stand-alone task that does part of the problem. Each can be tackled individually.

5) I recommend you break down each sub-question into smaller parts too, and figure out what needs to be done step-by-step. Then you can begin to put things together again to complete the whole.

6) To make it clear what must be provided as part of the solution, I have used bold italics and a statement that (usually) starts with a verb (e.g. Write a function ..., Print the value..., etc.)

QUESTION 1

Q1a. Following the above example, we transmit a set of modulated data from the base station to mobile handset, and the data file is saved to the file transmission_data.txt with an unknown number of lines. In this data file, there are some empty lines and some text lines.

Write a MATLAB script that will read all data from this file and skip the empty lines and text lines and store the data in a matrix called ‘signal'.

Output the size of the matrix ‘signal' to the command window.

Then using the command ‘fprintf', print out the entire matrix ‘signal' (each element in the matrix can be printed out using conversion specifier ‘%4d'). The print-out should be in the same format as the matrix ‘signal' (i.e., same row number, same column number, same values).

Q1b: At the receiver, we measure the error rates and store them in a file called ‘errorrate.txt'. These error rates are measured at different signal power-to-noise ratios in decibels (dB), which are stored in another file called ‘SNR.txt'.

Load both files into MATLAB and use the plot command ‘semilogy' to plot the error rate (y-axis) versus signal-to-noise ratio (x-axis). In this figure, use red circle data marker and a red solid line. Ensure the plot has a title called ‘Error rate curve'. Also add a background grid to the plot.

Q1c: Assuming the system conducts 10 transmissions; we measure the power level in dB for each transmission and write them to a file called ‘power.txt'.

- Load these data and compute the average power.

- Print out the average power using fprintf with a width of 10 characters and precision 2.

- Find the maximum power and use fprintf and conversion specifier ‘%d' to print out the result and start a new line after the print out.

- Find how many transmission powers are above this average and use fprintf and conversion specifier ‘%d' to print out the result, and start a new line after the print out.

Question 2

Q2a. Read in the pressure drop data from "Pressure_Drop.txt". You will need to skip over the header information.

(IMPORTANT NOTE: You MUST ensure that all units in your data are consistent, i.e. S.I. units - you cannot mix units.)

Create a figure with two sub-plots (one above the other). In the top sub-plot, plot dP vs V as a linear-linear plot, and in the lower sub-plot plot the same information in log-log coordinates (using the MATLAB plot command loglog). Ensure the appropriate units are included in the axis labels. Plot each data point as a red dot (do NOT join these symbols with a line). In both subplots, select ONLY those points with Φ = 0.05 and δ = 0.5) and plot these on the same plots as blue circles (there should be a red dot inside each one).

In the log-log plot, it will be obvious that the data appears to have a particular type of behaviour. Print a brief statement to the command window that describes this behaviour (no more than 3 lines of text).

Q2b. Write a function called PowerFit that does a non-linear curve fit to data of the form y=Axn. Input parameters are x and y, output parameters are A and n. Inside PowerFit, you can write your own code or use in-built MATLAB functions as you wish.

Q2c. As mentioned, the data has been measured at 4 different porosities (Φ = 0.05, 0.1, 0.2, 0.5) and 7 different thickness ratios (δ = 0.05, 0.1, 0.25, 0.5, 1.0, 2.0, 3.0) and a wide range of velocities. Unfortunately the data has been entered into the file in a random order. In order to estimate the exponent (n) in Eqn 1, you can ONLY consider data for one value of Φ and one value of δ at a time.

Calculate the curve of best fit using your function PowerFit for each pair of (Φ,δ) values separately (there are 4x7=28 different combinations).

Estimate the MEAN value of the exponent in the power law fit, (n) by averaging the values estimated for each (Φ,δ) pair. NOTE: if there are less than 5 data points for a given combination of (Φ,δ), then do not include the exponent estimate in the average as the data is not reliable for too few measurements.

Print the average value of the exponent to the command window (to 2 decimal places) AND print the number of different (Φ,δ) pairs that contributed to the average.

Q2d. Once you have found n, the next thing to do is to determine an appropriate function for f(δ). You can use ALL of the data in the file. For each line of data, calculate K(Φ) using Eqn 2 and Vn using the results of Q2c. Then calculate the value of f using Eqn 1 for each line of data in the file.

Perform a least squares polynomial fit to all of the (δ, f) values using polyfit with a third order polynomial - your output will be a set of coefficients that describe a polynomial p(δ) that is a lest squares approximation for f(δ).

Plot the values of f that you calculated with blue dots and the best fit polynomial p(δ) with a red line in the top subplot of a (new) figure. You will see that the curve fit is not that good.

Calculate the coefficient of determination and add it to the top subplot as a text label using the MATLAB command ‘text'.

Someone suggests that the data could be well-fitted with a function that is given by some polynomial p(δ) DIVIDED by δ (i.e. f(δ) ≈ p(δ)/δ ).

Using a suitable transformation of the data2, perform this alternative least squares fit (using a third order polynomial and polyfit).

In the lower subplot of the same figure, plot f with blue dots and the new best fit function (p(δ)/δ ) with a red line.

Calculate the coefficient of determination and add it to the lower subplot.

Print a brief statement to the command window as to which method is best and provide a possible reason for this.

Q2e. The shape of the best fit function in Q2d suggests that there is a minimum value of f(δ) somewhere in the range δ ∈[0.5, 3]. You are required to use the concepts discussed in Lecture 14 (associated with Optimization) to find this minimum.

Using the best fit function from the second part of Q2d (i.e. p(δ)/δ ) and a root finding technique, find this minimum value and the value of δ at which it occurs. You can use any root finding technique you like including MATLAB's fzero. To use root finding, you will also need to write a function that returns the derivative of (p(δ)/δ ). If you want, you can use the MATLAB function "min" to check your answer to this part of the question, but you cannot provide this as your solution.

Print the minimum f(δ) and the value of δ at which it occurs to the command window. Add a solid green circle to the second subplot in Q2d that represents this minimum point.

Write a brief comment to the command window that describes what this minimum point represents physically.

You have to complete all the questions in the templates given in the zip file

Attachment:- Templates.rar

Reference no: EM131044448

Questions Cloud

Sports history project-controversy in your sport : Term 7 - Sports History Project - Controversy in Your Sport. For this term your project will be a 2-3 page informative essay on a controversy that your sport had to deal with.
What is the weighted average cost : People's bank will lend 2,450,000 and wants 11% interest on the loan. If all of these interest rates are after-tax, what is the weighted average cost of capital for this project.
Analyze the competitive advantage of each company : Evaluate the effectiveness of the measurement guidelines that each company uses.
What is the resulting impact on the number of people : Your friend has a new job as mechanical engineer helping design bridges. He designs his main support beam to support for a cross sectional area of 100 inA2, made from a Al-4% Cu alloy, treated to produce the highest strength. During production, a ..
Perform a least squares polynomial fit : ENG1060 ASSIGNMENT - Calculate the coefficient of determination and add it to the lower subplot and print a brief statement to the command window as to which method is best and provide a possible reason for this.
New stories surrounding concussions : Your final paper for Sports History will be to add a new final chapter to League of Denial. Since the publishing of this groundbreaking work or sports journalism there have been so many new stories surrounding concussions, football and the NFL.
What will be the cost of equity : The remaining 50% ($679,207,425) will be financed through equity as a 2:1 stock split. What will be the cost of equity?
What are the basics characteristics of your target market : What stage is Coca Cola's product at in the product life cycle? Explain your answer.
Share on facebookshare on twitter : Apple Inc.'s share decline Wednesday wiped almost $43 billion off the iPhone-maker's market value in just one hour. That's more than the entire market capitalization of multinationals such as Deutsche Bank AG and Glencore Plc, as well as technolog..

Reviews

Write a Review

 

MATLAB Programming Questions & Answers

  What are corresponding displacement field and strain field

Write a short Matlab (or whatever language you prefer) program to perform 2 point Gauss integration of a function f over a given interval (a, b). Inputs: a, b, and the functional values of f at the two Gauss points x1 and x2, f 1) and f (x2). (The..

  Problems related to matlab

solve the system for the least-squares estimates of Δρi.

  Perform gauss-jordan elimination

Write a matlab function to perform gauss-jordan elimination with pivoting. Modify the pivoting so that it is using the row with the highest absolute value rather than the first non-zero row.

  Build a simple revolvate robot

Define the robot as Robot.  Use the appropriate functions (i.e. methods) in the Robotics Toolbox - Generate a second pose and re-plot it.

  Finite difference method

Use the finite difference method to calculate the temperature at the point specified since it is easier.

  Write a function named ''read_line''

Verify that your code works by saving some text into a file (created in notepad / textedit) and saving the file with extension '.txt'. You should attach the file (call it 'test.txt') with your code.

  Analysis of the changes to the external environment

Analysis of the changes to the external environment that may, or have, influenced the value chain for Australian wine producers over the last six (6) years.

  Find the corresponding equilibrium value for the air speed

Find the corresponding equilibrium value for the airspeed. There are several solutions for the airspeed, we take the higher value and Find the two operating points in terms of Pm and other variables - Find the linearized system near each of the oper..

  Implement linear support vector machine to classify data

code to implement linear Support vector machine to classify data (without using matlab built in function).

  Determine the size for variables used in matlab program

If b=3, a=6 how many loops would the given program do? what will be the out put for z(4)? what would be size (in rows and columns) for variables z, i and b?

  Write a matlab script that solves ode

Write a matlab script that solves ODE: y' = 4/(1+x^2) using forward Euler's, improved Euler, classical Runge-Kutta, and Adams-Bashforth methods.

  Perform a principal component analysis on the dataset

Perform a principal component analysis on the dataset you have generated - what is the total variability in the dataset and what is the percent of the total variability explained by the first three components?

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd