Import the data from "Q5 Data.mat" on eClass. We have already imported scipy.io as sio so that we can use SciPy's loadmat function. Unfortunately, the CSVS we've been using up to now are not well-suited for 3D matrices of data. If you print your data after importing it, you may notice that there's a header followed by some data. However, the MAT file is being stored as a dictionary rather than a list, so we can't just index into it using myData[0] or myData[1];we need to use the correct key instead as in myData['correctKey']. Dictionaries will tell you what keys are stored in them if you use myData. keys(). Look at the keys available to you, and use the correct key to store just the data array to a new variable. This is now a regular matrix and you can index into it as you usually would. myMatrix[0, 0] should get you a list in the form [x, y, z] where x and y are just the x and y coordinates on the sheet of paper, and z is the voltage at that point. Plot a 3D surface plot of the data and a contour plot of the data. You can use either plt.contour or plt.contourf for the contour plot, but contourf is more fun to look at. Because the data array pulled from the MAT file is an M*N*3 matrix, if we slice it correctly, we qan get the three, 2D matrices that we need as both types of plots are expecting three arguments-X, Y, and Z-each of which is a 2D matrix. We don't require axis labels this time for either plot, though you may want to try adding them.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
Plz help with code
Import the data from "Q5 Data.mat" on eClass. We have already imported scipy.io as sio so that we can use SciPy's loadmat function.
Unfortunately, the CSVS we've been using up to now are not well-suited for 3D matrices of data. If you print your data after importing it, you may
notice that there's a header followed by some data. However, the MAT file is being stored as a dictionary rather than a list, so we can't just index
into it using myData[0] or myData[1];we need to use the correct key instead as in myData['correctKey']. Dictionaries will tell you what
keys are stored in them if you use myData.keys(). Look at the keys available to you, and use the correct key to store just the data array to a
new variable. This is now a regular matrix and you can index into it as you usually would. myMatrix[0, 0] should get you a list in the form [x,
y, z] where x and y are just the x and y coordinates on the sheet of paper, and z is the voltage at that point.
Plot a 3D surface plot of the data and a contour plot of the data. You can use either plt.contour or plt.contourf for the contour plot, but
contourf is more fun to look at. Because the data array pulled from the MAT file is an M *N*3 matrix, if we slice it correctly, we qan get the
three, 2D matrices that we need as both types of plots are expecting three arguments-X, Y, and Z-each of which is a 2D matrix. We don't
require axis labels this time for either plot, though you may want to try adding them.
Surface Plot: https://matplotlib.org/stable/gallery/mplot3d/surface3d 2.html
Contour Plot: https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.contour.html
# your code here
Transcribed Image Text:Import the data from "Q5 Data.mat" on eClass. We have already imported scipy.io as sio so that we can use SciPy's loadmat function. Unfortunately, the CSVS we've been using up to now are not well-suited for 3D matrices of data. If you print your data after importing it, you may notice that there's a header followed by some data. However, the MAT file is being stored as a dictionary rather than a list, so we can't just index into it using myData[0] or myData[1];we need to use the correct key instead as in myData['correctKey']. Dictionaries will tell you what keys are stored in them if you use myData.keys(). Look at the keys available to you, and use the correct key to store just the data array to a new variable. This is now a regular matrix and you can index into it as you usually would. myMatrix[0, 0] should get you a list in the form [x, y, z] where x and y are just the x and y coordinates on the sheet of paper, and z is the voltage at that point. Plot a 3D surface plot of the data and a contour plot of the data. You can use either plt.contour or plt.contourf for the contour plot, but contourf is more fun to look at. Because the data array pulled from the MAT file is an M *N*3 matrix, if we slice it correctly, we qan get the three, 2D matrices that we need as both types of plots are expecting three arguments-X, Y, and Z-each of which is a 2D matrix. We don't require axis labels this time for either plot, though you may want to try adding them. Surface Plot: https://matplotlib.org/stable/gallery/mplot3d/surface3d 2.html Contour Plot: https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.contour.html # your code here
Expert Solution
steps

Step by step

Solved in 3 steps with 3 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY