Eng1060 assignment - calculate the coefficient of


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

Request for Solution File

Ask an Expert for Answer!!
MATLAB Programming: Eng1060 assignment - calculate the coefficient of
Reference No:- TGS01390323

Expected delivery within 24 Hours