Home Teaching Research CV Timetable

Prev: P3 Next: P5
Back to week 7 page: Link



# P4 Programming Problem Instruction

📗 Enter your ID (the wisc email ID without @wisc.edu) here: and click (or hit enter key)
📗 The due date is Mar 16, late submissions within a week will be accepted without penalty, but please submit a regrade request form: Link.
📗 The same ID should generate the same set of questions. Your answers are not saved when you refresh the page or close the browser.
📗 To input your answers, you could (1) copy and paste your answers to the text boxes for individual questions, or (2) print your answers to text files and load them into the text boxes for individual questions, or (3) print all your outputs to a single text file and load it using the button at the bottom of the page under the Submission section. More details at the bottom of page W1.
📗 Please report any bugs on Piazza.

# Warning: please enter your ID before you start!



# Questions 1 to 2 Instruction

📗 Read two rows of data points containing a list of positions that a train track must pass through. Create a polynomial with degree ??? that passes through all the points. Enter the polynomial coefficients (for degrees ???) as a vector and the x-coordinates and y-coordinates of the polynomial evaluated at \(x\) = ??? as two rows of a matrix, the same format as the data file.
📗 Note: if there is an error message about the polynomial being badly conditioned, you can fit a polynomial with a lower degree and add 0s in front for the highest degree terms.
📗 The data points (row 1 is the x-coordinate and row 2 is the y-coordinate):

# Question 1

📗 [1 point] Enter the coefficients as a vector.
📗 Note: please use "mat2str" to convert the matrix to string without rounding (or output the matrix to a file without rounding). The auto-grader is unable to verify the correctness of the coefficients if they are rounded.
📗 Answer:


# Question 2

📗 [1 point] Enter the x-values and y-values as two rows of a matrix.
📗 Answer:


# Questions 3 to 4 Instruction

📗 Read two rows of data points containing a list of positions that a train track must pass through. Create a spline with degree ??? that passes through all the points. Enter the local coefficients (for degrees ???), one row corresponding to one piece of local polynomial, as a matrix and the x-coordinates and y-coordinates of the polynomial evaluated at \(x\) = ??? as two rows of a matrix, the same format as the data file.
📗 The data points (row 1 is the x-coordinate and row 2 is the y-coordinate):

# Question 3

📗 [1 point] Enter the coefficients as a matrix.
📗 Note: please use "mat2str" to convert the matrix to string without rounding (or output the matrix to a file without rounding). The auto-grader is unable to verify the correctness of the coefficients if they are rounded.
📗 Answer:


# Question 4

📗 [1 point] Enter the x-values and y-values as two rows of a matrix.
📗 Answer:


# Questions 5 to 6 Instruction

📗 Read two rows of data points containing a list of positions that a train track should try to be close to. Create a polynomial with degree ??? that minimizes the sum of squared distances to the points. Enter the polynomial coefficients (for degrees ???) as a vector and the x-coordinates and y-coordinates of the polynomial evaluated at \(x\) = ??? as two rows of a matrix, the same format as the data file.
📗 The data points (row 1 is the x-coordinate and row 2 is the y-coordinate):

# Question 5

📗 [1 point] Enter the coefficients as a vector.
📗 Note: please use "mat2str" to convert the matrix to string without rounding (or output the matrix to a file without rounding). The auto-grader is unable to verify the correctness of the coefficients if they are rounded.
📗 Answer:


# Question 6

📗 [1 point] Enter the x-values and y-values as two rows of a matrix.
📗 Answer:


# Questions 7 to 9 Instruction

📗 Create a matrix of values representing temperatures of tiles arranged in an \(n\) by \(m\) rectangular grid, satisfying the condition that the temperature in a tile is equal to the average temperature of the surrounding tiles. For example, if \(n = m = 3\), then the temperatures \(\begin{bmatrix} T_{i} & T_{11} & T_{12} & T_{13} & - \\ - & T_{23} & T_{22} & T_{23} & - \\ - & T_{31} & T_{32} & T_{33} & T_{o} \end{bmatrix}\) satisfy \(T_{11} = \dfrac{1}{3} \left(T_{i} + T_{12} + T_{21}\right)\), \(T_{12} = \dfrac{1}{3} \left(T_{11} + T_{22} + T_{13}\right)\), \(T_{13} = \dfrac{1}{2} \left(T_{12} + T_{23}\right)\), \(T_{22} = \dfrac{1}{4} \left(T_{12} + T_{21} + T_{23} + T_{32}\right)\), and so on. In this case, you will get 9 linear equations and 9 unknowns. Use the values of \(n\), \(m\), and the values of \(T_{i}\) and \(T_{o}\) specified by each question. Enter the matrix you created in the text box below each question.
📗 Note: creating the coefficient matrix is difficult, especially without for loops and if conditionals, if you don't want to write the code yourself, you can use this example function to create the matrix: .m File or .txt File.

# Question 7

📗 [1 point] Create the matrix of temperatures for an \(n\) = ??? by \(m\) = ??? grid with \(T_{i}\) = ??? and \(T_{o}\) = ???.
📗 Answer:


# Question 8

📗 [1 point] Create the matrix of temperatures for an \(n\) = ??? by \(m\) = ??? grid with \(T_{i}\) = ??? and \(T_{o}\) = ???.
📗 Answer:


# Question 9

📗 [1 point] Create the matrix of temperatures for an \(n\) = ??? by \(m\) = ??? grid with \(T_{i}\) = ??? and \(T_{o}\) = ???.
📗 Answer:


# Question 10

📗 [1 point] Please enter any comments and suggestions including possible mistakes and bugs with your version of the questions and the auto-grading, and materials relevant to solving the question that you think are not covered well during the lectures. If you have no comments, please enter "None": do not leave it blank.
📗 Answer: .

# Grade


 ***** ***** ***** ***** ***** 

 ***** ***** ***** ***** *****

# Submission



📗 Please do not modify the content in the above text field: use the "Grade" button to update.
📗 Warning: grading may take a few seconds. Please be patient and do not click "Grade" multiple times.


📗 You could submit multiple times (but please do not submit too often): the submission with the highest grade will be counted.
📗 Please also save the text in the above text box to a file using the button or copy and paste it into a file yourself .
📗 You could also load your answers from the text (or txt file) in the text box below using the button . The first two lines should be "##p: 4" and "##id: your id", and the format of the remaining lines should be "##1: your answer to question 1" newline "##2: your answer to question 2", etc. Please make sure that your answers are loaded correctly before submitting them.



📗 Saving and loading may take a few seconds. Please be patient and do not click "Load" multiple times.

# Code

📗 Please submit your code (.m, .txt, or .pdf are all acceptable) on Canvas Assignment P4.
📗 Your coding style and technique will not be graded, but please consider the following:
(1) Add comments to describe what the code is doing.
(2) Indent "for" loops and "if" blocks.
(3) Use descriptive but short variable names.
(4) Add white spaces and/or blank lines for readability.
📗 It is highly recommended that you use the commands and functions from the lectures, but you are allowed to use any built-in MATLAB commands and functions.
📗 Example solution: .m File, .txt File .pdf File.
(1) Please do not use the example solution as the starter code. You should write all the code yourself and only use the example solution as a reference when you get stuck.
(2) Please do not use the example solution as a guide for coding style. It is written so that it only solves a specific version of the problems. You code should be more general: you should define variables for constants, define functions for repetitive actions, and use descriptive variable names.
📗 Please report possible mistakes in the solution, and if you have better (shorter or more efficient) ways of solving the same problem, you can share your code on Piazza (but please do so after the due dates).
📗 If you use one or more lines of code from the example solution, other students in the class, or code you found on the Internet, you must give attribution by putting a comment at the beginning of your code submission, for example:
% Code attribution: P4 example solution.
% Code attribution: (student name)'s P4 solution.
% Code attribution: (student name)'s answer on Piazza: (link to Piazza post).
% Code attribution: (person name)'s answer on Stack Overflow: (link to page).






Last Updated: April 29, 2024 at 1:11 AM