辅导案例-ELEC6238

  • May 15, 2020

ELEC6238 Research Skills and Practice Matlab coursework This coursework forms your assessment for the Matlab part of ELEC6238 Research Skills and Practice. This coursework contributes 40% of your mark for ELEC6238 and completing it should require up to 47 hours of work outside the scheduled lectures and labs. Please do not spend any more time than this because I’m sure you have better things to be doing! However, you should make sure that you get started on this coursework early enough to finish it before the deadline. There’s no way that you can complete a 47-hour coursework in only the week before the deadline. In the exercises detailed below, you are asked to write some Matlab code and produce some results. Al- though you may verbally discuss your ideas with your classmates, you should not show them your Matlab code or results. When you are finished, you should copy and paste your Matlab code and results into a Word document, which you should then save as a .pdf file. This Word document should only include the Matlab code and results that are directly requested in the bold paragraphs below – it should not include anything else. In particular, there is no need to write a report for this coursework. When you are finished, you need to submit the .pdf version of your Word document, your Matlab code and your result files to the electronic handin system1 before 4pm on Friday 1st November 2019. As shown in the marking scheme of Table 1, one third of your marks in this coursework depend on each of the functionality, efficiency and human-readability of your Matlab code. I will mark the human-readability of your Matlab code by looking at your Word document. I will also look at the results in your Word document to assess some aspects of your Matlab code’s functionality and efficiency. However, I will also run your Matlab code on my computer to assess its functionality and efficiency more thoroughly. I will do this using Matlab scripts that are similar to the ones you can download from the ELEC6238 resources webpage2. Note however that my versions of these scripts include some additional tests, so you need to ensure that your Matlab code works in the general case, not just for the specific tests that are included in the scripts on the ELEC6238 resources webpage. Some of the tests in these scripts produce measurements, which I will use to mark the functionality and efficiency of your Matlab code. Some of the tests produce pass or fail messages and I will give higher marks for your Matlab code’s functionality if it can pass more of these tests. Note that some of these tests deliberately give erroneous inputs to your Matlab code. In order to pass these tests, your Matlab code will need to generate an error message using a command like the following one. error(‘Soton:argChk’,’Your error message goes here’); I will return your marks and the results of running your Matlab code on my computer to you within four weeks of the submission deadline. You can see how to interpret your marks in Table 2. I will also give some general feedback and show you my solutions to the exercises in the ELEC6238 lecture that we have at the end of the semester. If you notice any mistakes in this document or have any queries about it, please email me4. Have fun! Rob Maunder 1The URL for this is https://handin.ecs.soton.ac.uk/handin/1920/ELEC6238/2/. 2The URL for this is https://secure.ecs.soton.ac.uk/notes/elec6238/matlab/coursework.zip 3You can see discussions of good Matlab programming practice at http://www.mit.edu/∼pwb/cssm/GMPP.pdf and http://www.datatool.com/downloads/matlab_style_guidelines.pdf. 4My email address is [email protected] 1 Table 1: Marking scheme 33.33% Functionality. Does the Matlab code work? Does it meet the specifications provided in the exercises below? Are the results correct? Does the Matlab code generate appropriate error mes- sages? 33.33% Efficiency. How quickly does the Matlab code run? Has the Mat- lab code made good use of built in functions, vectors and matri- ces? Or does it use proprietary code and an excessive number of for loops? 33.33% Human-readability. Is the Matlab code reusable, elegant and well structured? Does it follow good programming practice3? Does it include useful, concise and relevant comments, which help ex- plain its non-trivial features? Are the chosen variable names de- scriptive, concise and relevant? Or does the Matlab code use an excessive number of lines? Does the Matlab code use switch, break, continue or return without having a really really good reason to? Table 2: How to interpret your marks 40 out of 40 Perfect solutions. This mark is only given if I can’t think of any ways to improve the functionality, efficiency or human- readability of the Matlab code and results. 29–39 out of 40 Excellent solutions. These marks are awarded to students that have really thought about their solutions and have come up with clever ways to optimise the functionality, efficiency and human- readability of the Matlab code and results. 28 out of 40 Solid solutions. All of the results are correct and the Matlab code is reasonably functional, efficient and human-readable, but all the tricks for making them particularly so have been missed. 20–27 out of 40 Flawed solutions. Typically, these marks are given if all parts of all exercises have been completed, but there are mistakes in the results or Matlab code. For example, the Matlab code may work for the specific tests provided in the scripts on the ELEC6238 resources webpage, but it may not always work in the general case. 1–19 out of 40 Missing solutions. Typically, marks this low are only given if some of the results or Matlab code are missing from the submis- sion. To avoid this you should make sure you budget 47 hours for completing this coursework outside of the scheduled lectures and labs. 0 out of 40 No solutions. You would probably have to submit nothing at all to get a mark this low! 2 Exercise 1 – Two-dimensional parity check encoder Consider a wireless communication scheme which is designed to convey messages between a transmitter and a receiver over a wireless channel. Suppose that each message is a row vector x comprising k number of symbols. Each symbol has an integer value in the range 0 to (M − 1), where M is known as the radix of the symbols. For example, the message vector x = [2, 0, 1, 1, 3, 2] comprises k = 6 symbols, having a radix of M = 4. A Two-Dimensional Parity Check (TDPC) encoder may be used in the transmitter to protect the message vector x from the corruption that may be imposed by the wireless channel, owing to noise, fading and interfer- ence, for example. A TDPC encoder is controlled using three parameters, namely the radix M, the number of rows i in the TDPC matrix and the number of columns j in the TDPC matrix. The TDPC encoder can be used to encode a message vector x comprising k symbols, provided that the radix M of the TDPC encoder and of the message are equal, and provided that the number of rows i and columns j are set such that (i − 1) · ( j − 1) = k. The first step in TDPC encoding is to reshape the vector x, so that it becomes a matrix X, having (i−1) rows and ( j − 1) columns. Taking each of the symbols in x from left to right in turn, the matrix X is populated one column at a time, starting by filling the left-most column from top to bottom, before similarly filling each of the other columns from left to right in turn. In the case where the example message vector x = [2, 0, 1, 1, 3, 2] is TDPC encoded using the parameters i = 3 and j = 4, we obtain the matrix X = [ 2, 1, 3 0, 1, 2 ] , which has (i − 1) = 2 rows and ( j − 1) = 3 columns. In a second step, the TDPC matrix Y is formed by copying the matrix X, but adding an extra row at the bottom and an extra column at the right. Therefore, the TDPC matrix Y has i rows and j columns. The values in the extra row are set such that each column has a sum that is a multiple of M. Likewise, the values in the extra column are set such that each row has a sum that is a multiple of M. In the case where the example message vector x = [2, 0, 1, 1, 3, 2] is TDPC encoded using the parameters i = 3 and j = 4, we obtain the TDPC matrix Y = 2, 1, 3, 20, 1, 2, 1 2, 2, 3, 1 , which has i = 3 rows and j = 4 columns. Note that the first, second and fourth columns of this example Y have sums of 4, while the third column has a sum of 8. Likewise, the second row has a sum of 4, while the first and third rows have sums of 8. Note that these values of 4 and 8 are both multiples of M = 4. In other words, a remainder of zero results when dividing the sum of each row and column by M = 4, which is to say that the modulo-M = 4 sum of each row and each column is zero. In a final step, the TDPC matrix Y is reshaped, so that it becomes a row vector y, having a length of (i · j). Taking each of the columns in Y from left to right in turn and reading the columns from top to bottom, the row vector y is populated one symbol at a time, from left to right. In the case where the example message vector x = [2, 0, 1, 1, 3, 2] is TDPC encoded using the parameters i = 3 and j = 4, we obtain the encoded vector y = [2, 0, 2, 1, 1, 2, 3, 2, 3, 2, 1, 1], which comprises n = i · j = 12 symbols. In this exercise, your task is to write a Matlab function which performs TDPC encoding. Your Matlab function is required to use the following line, in order to declare the function’s name, inputs and outputs. function encoded_vector = TDPC_encoder(message_vector, radix, rows, columns) Here, message_vector should accept the row vector x, while radix, rows and columns should accept the scalars M, i and j, respectively. Your TDPC_encoder function should check that the values of these inputs are self-consistent and if not, it should generate an error message using the command provided on page 1. Otherwise, encoded_vector should return the row vector y. You can test the functionality and efficiency of your TDPC_encoder function using the script test_TDPC_encoder, which you can download from the ELEC6238 resources webpage. I will use a script similar to this one to mark the functionality and efficiency of your TDPC_encoder function. Note that the mark that you receive for efficiency in this exercise will be capped by the mark that you receive for functionality. This is because it is easy to write a Matlab function that runs quickly, but does not have all of the required functionality. When you are finished, include a listing of your TDPC_encoder function in your Word document and submit this function to the electronic handin system. 3 Exercise 2 – Two-dimensional parity check decoder In the wireless communication scheme mentioned in Exercise 1, the encoded vector y is conveyed between the transmitter and the receiver over a wireless channel. This channel may suffer from noise, interference and fading, causing the encoded vector to become corrupted. Owing to this, some of the symbols in the received vector yˆ may have different values to the corresponding symbols in the encoded vector y. Note however that these erroneous symbols should still have integer values in the range 0 to (M − 1). For example, the wireless channel could corrupt the encoded vector y = [2, 0, 2, 1, 1, 2, 3, 2, 3, 2, 1, 1], resulting in the received vector yˆ = [2, 1, 2, 1, 1, 2, 1, 2, 3, 2, 1, 1], which contains two erroneous symbols. A TDPC decoder may be employed in the receiver to mitigate the erroneous symbols in the vector yˆ. A TDPC decoder is controlled using three parameters, namely the radix M, the number of rows i in the TDPC matrix and the number of columns j in the TDPC matrix. The TDPC encoder can be used to decode a received vector yˆ, provided that it derives from an encoded vector y that has been generated using a TDPC encoder having the same parameter values. The first step in TDPC decoding is to reshape the received vector yˆ of n symbols, so that it becomes the TDPC matrix Yˆ, having i rows and j columns, where i · j = n. Taking each of the symbols in yˆ from left to right in turn, the TDPC matrix Yˆ is populated one column at a time, starting by filling the left-most column from top to bottom, before similarly filling each of the other columns from left to right in turn. In the case where the example received vector yˆ = [2, 1, 2, 1, 1, 2, 1, 2, 3, 2, 1, 1] is TDPC decoded using the parameters i = 3 and j = 4, we obtain the TDPC matrix Yˆ = 2, 1, 1, 21, 1, 2, 1 2, 2, 3, 1 , which has i = 3 rows and j = 4 columns. In a second step, the modulo-M sum of each row and each column is calculated and analysed to identify and mitigate erroneous symbols. In the case of the example received vector yˆ = [2, 1, 2, 1, 1, 2, 1, 2, 3, 2, 1, 1], the modulo-M = 4 sums of the columns in Yˆ are [1, 0, 2, 0], while the modulo-M = 4 sums of its rows are 21 0 . Note that the third row, the second column and the fourth column all have modulo-M = 4 sums of 0, just as was desired when setting the values in the extra row and column during TDPC encoding. This suggests that there are no erroneous symbols in these rows and columns. However, the modulo-M = 4 sums of the second row and of the first column are both equal to 1. This suggests that the symbol in the second row and the first column has an erroneous value, which has been obtained using the modulo-M = 4 addition of the value 1 to the correct symbol value. More specifically, this suggests that the correct value for this symbol is 0, rather than 1. Likewise, the modulo-M = 4 sums of the first row and of the third column are both equal to 2. This suggests that the symbol in the first row and the third column has an erroneous value, which has been obtained using the modulo-M = 4 addition of the value 2 to the correct symbol value. More specifically, this suggests that the correct value for this symbol is 3, rather than 1. Using this logic, it can be inferred that the correct value for the TDPC matrix is Yˆ = 2, 1, 3, 20, 1, 2, 1 2, 2, 3, 1 . In a fourth step, the bottom row and the right-most column of the TDPC matrix Yˆ are removed, to obtain the matrix Xˆ. In the case of the example received vector yˆ = [2, 1, 2, 1, 1, 2, 1, 2, 3, 2, 1, 1], removing this row and this column from the TDPC matrix Yˆ results in the matrix Xˆ = [ 2, 1, 3 0, 1, 2 ] , which has (i − 1) = 2 rows and ( j − 1) = 3 columns. In a final step, the matrix Xˆ is reshaped, so that it becomes a row vector xˆ, having a length of k = (i−1)·( j−1). Taking each of the columns in Xˆ from left to right in turn and reading the columns from top to bottom, the row vector xˆ is populated one symbol at a time, from left to right. In the case where the example received vector yˆ = [2, 1, 2, 1, 1, 2, 1, 2, 3, 2, 1, 1] is TDPC decoded using the parameters i = 3 and j = 4, we obtain the decoded vector xˆ = [2, 0, 1, 1, 3, 2], which comprises k = (i − 1) · ( j − 1) = 6 symbols. Note this decoded vector xˆ is identical to the message vector x from Exercise 1, indicating that all erroneous symbols in the vector yˆ have been successfully mitigated. Note that in the example above, the symbol errors have occurred in different rows and columns of the TDPC matrix Yˆ. Also, the rows and columns have the same set of modulo-M sums, with no repetitions within this set. 4 This has made it easy to mitigate all of the symbol errors. However, on other occasions it can be more difficult or impossible to mitigate all of the symbol errors. For example, some symbol errors may occur in the same row or column. Sometimes, these symbol errors can cancel each other out, causing the row or column to have a modulo-M sum of zero. Other times, these symbol errors can cause the rows and columns to have different sets of modulo-M sums. Furthermore, some rows or some columns may have the same modulo-M sums. In this exercise, your task is to write a Matlab function which performs TDPC decoding and mitigates as many symbol errors as you can. Your Matlab function is required to use the following line, in order to declare the function’s name, inputs and outputs. function decoded_vector = TDPC_decoder(received_vector, radix, rows, columns) Here, received_vector should accept the row vector yˆ, while radix, rows and columns should accept the scalars M, i and j, respectively. Your TDPC_decoder function should check that the values of these inputs are self-consistent and if not, it should generate an error message using the command provided on page 1. Otherwise, decoded_vector should return the row vector xˆ. You can test the functionality and efficiency of your TDPC_decoder function using the script test_TDPC_decoder, which you can download from the ELEC6238 resources webpage. Here, tests 1 to 7 can be used to evaluate the functionality of your TDPC_- decoder function. Tests 8 to 17 can be used to evaluate whether your TDPC_decoder function can mitigate particular combinations of symbol errors. It is possible to write a TDPC_decoder function that can mitigate all of the symbol errors in tests 8 to 17, although some require much more complicated programming than others. I would advise you to finish Exercises 3 and most of Exercise 4, before attempting to pass all of tests 8 to 17. Finally, tests 18 to 20 can be used to evaluate the overall error mitigation and efficiency of your TDPC_decoder function. I will use a script similar to the one you can download from the ELEC6238 resources webpage to mark the functionality and efficiency of your TDPC_decoder function. I will consider all of the tests when marking the functionality of your TDPC_decoder function, but I will pay particular attention to the results of tests 18 to 20. Note that the mark that you receive for efficiency in this exercise will be capped by the mark that you receive for functionality. This is because it is easy to write a Matlab function that runs quickly, but does not have all of the required functionality. When you are finished, include a listing of your TDPC_decoder function in your Word document and submit this function to the electronic handin system. 5 Exercise 3 – M-ary symmetric channel In the wireless communication scheme mentioned in Exercises 1 and 2, an encoded vector y of n symbols having values in the range 0 to (M − 1) is conveyed over a wireless channel. The resulting received vector yˆ also comprises n symbols having integer values in the range 0 to (M − 1), although some of these may have different values to the corresponding symbols in the encoded vector y. The occurrence of these symbol errors may be (crudely) modelled using an M-ary symmetric channel. An M-ary symmetric channel is parametrised by two parameters, namely the symbol error probability Pe in the range 0 to 1 and the radix M, which is required to equal the radix M of the encoded vector y. The transmission of each of the n symbols in the encoded vector y is modelled separately and independently, by generating a random number. Depending on the value of the random number, the value of symbol will be either copied to the corresponding symbol in the received vector yˆ without error, or will be replaced with a different value in the range 0 to (M − 1). This is performed such that a symbol error is avoided with a probability of (1 − Pe) and incurred with a probability of Pe. When a symbol error occurs, the value for the symbol in the received vector yˆ is selected from among the (M − 1) possible incorrect values, each with the same probability of 1/(M − 1). Therefore, the overall probability of receiving a particular one of these incorrect values is given by Pe · 1/(M − 1). For example, consider the transmission of an M = 4-ary symbol value of 2 over an M = 4-ary symmetric channel having a symbol error probability of Pe = 0.3. With a probability of (1 − Pe) = 0.7, the symbol will be correctly received with a value of 2. However, with a probability of Pe = 0.3, the symbol will be received incorrectly, with a value of either 0, 1 or 3. In this event, each of these incorrect values is associated with an equal probability of 1/(M − 1) = 0.333. Therefore, the overall probability of receiving the incorrect value of 0 is given by Pe · 1/(M − 1) = 0.1. Likewise, the probabilities of receiving the incorrect values of 1 and 3 are also both equal to 0.1. Note that the probabilities of receiving the four possible symbol values in the set {0, 1, 2, 3} are given by the set {0.1, 0.1, 0.7, 0.1}, which sum to 1.0, as may be expected. In this exercise, your task is to write a Matlab function which simulates transmission over an M-ary sym- metric channel. Your Matlab function is required to use the following line, in order to declare the function’s name, inputs and outputs. function received_vector = MSC(encoded_vector, radix, Pe) Here, encoded_vector should accept the row vector y, while radix and Pe should accept the scalars M and Pe, respectively. Your MSC function should check that the values of these inputs are self-consistent and if not, it should generate an error message using the command provided on page 1. Otherwise, received_vector should return the row vector yˆ. You can test the functionality and efficiency of your MSC function using the script test_MSC, which you can download from the ELEC6238 resources webpage. I will use a script similar to this one to mark the functionality and efficiency of your MSC function. Note that the mark that you receive for efficiency in this exercise will be capped by the mark that you receive for functionality. This is because it is easy to write a Matlab function that runs quickly, but does not have all of the required functionality. When you are finished, include a listing of your MSC function in your Word document and submit this function to the electronic handin system. 6 Exercise 4 – Monte-Carlo simulation The error mitigation ability of the wireless communication scheme mentioned in Exercises 1, 2 and 3 may be characterised using a Monte-Carlo simulation. Here, we can simulate the TDPC encoding of lots of message vectors x, as well as their transmission over an M-ary symmetric channel having a particular symbol error probability Pe, while counting the total number of symbol errors in the decoded vectors xˆ produced by the TDPC decoder. The Symbol Error Ratio (SER) is given by the total number of symbol errors in the decoded vectors xˆ divided by the total number of symbols in the message vectors x. We can repeat this experiment for a range of different values for the symbol error probability Pe and plot the resultant SERs against Pe on logarithmic axes, as exemplified in Figure 1. If a sufficiently high number of message vectors x have been used during the simulation for each value of the symbol error probability Pe, then a nice smooth SER plot will result. Note that the plots of Figure 1 were obtained by using 16 processors on one node of the Lyceum2 supercomputer5 for 24 hours. Each data point was obtained by continuing to generate new message vectors x, until 10000 symbol errors had been observed in the corresponding decoded vectors xˆ. In this exercise, your task is to write a Matlab script or function that performs a Monte-Carlo simulation of the wireless communication scheme mentioned in Exercises 1, 2 and 3. This script or function should use an ASCII text file to save the total number of symbol errors observed in the decoded vectors xˆ, as well as the total number of symbols in the message vectors x, for each value of the symbol error probability Pe considered. Your Matlab script or function should also plot the SER against the symbol error probability Pe on logarithmic axes, as exemplified in Figure 1. Alternatively, you may prefer to use a second Matlab script or function to perform the plotting. In this exercise, you may find it helpful to use a number of Matlab’s built in functions, such as save, load, figure, subplot, title, xlabel, ylabel, xlim, ylim, box, hold, loglog and legend. I will mark the functionality of your Matlab code by assessing the quality of your SER plot(s). More specifically, I will be hoping to see nice smooth SER curves that are well annotated, that consider a good selection of parameter values and that include results for a good selection of symbol error probability Pe values. I will mark the efficiency of your Matab code by looking at your ASCII text file. In particular, I will be hoping to see that each SER value has been calculated using an appropriate number of symbol errors in the decoded vectors xˆ, as well as an appropriate number of symbols in the message vectors x. When you are finished, include a listing of your Matlab scripts and/or functions in your Word docu- ment, together with your SER plot(s) and one example of your ASCII text files. Also, submit these items to the electronic handin system. 5You can find out more about Lyceum2 at http://www-mobile.ecs.soton.ac.uk/newcomms/?q=resources/lyceum/matlab 7 10−410−310−210−1100 10−6 10−4 10−2 100 M=2−ary TDPC SE R Pe i=2 j=2 i=3 j=3 i=4 j=4 i=5 j=5 10−410−310−210−1100 10−6 10−4 10−2 100 M=4−ary TDPC SE R Pe i=2 j=2 i=3 j=3 i=4 j=4 i=5 j=5 10−410−310−210−1100 10−6 10−4 10−2 100 M=8−ary TDPC SE R Pe i=2 j=2 i=3 j=3 i=4 j=4 i=5 j=5 10−410−310−210−1100 10−6 10−4 10−2 100 M=16−ary TDPC SE R Pe i=2 j=2 i=3 j=3 i=4 j=4 i=5 j=5 Figure 1: SER plots for TDPC codes having various combinations of radix M ∈ {2, 4, 8, 16}, rows i ∈ {2, 3, 4, 5} and columns j ∈ {2, 3, 4, 5}, when communicating over an M-ary symmetric channel. 8

LATEST POSTS
MOST POPULAR

ezAce多年来为广大留学生提供定制写作、留学文书定制、语法润色以及网课代修等服务,超过200位指导老师为您提供24小时不间断地服务。