Arrays & plotting

Python for MATLAB Users

Justin Kiggins

Product Manager

NumPy arrays

  • Arrays = matrices
  • Arrays can be multidimensional
  • Every element is the same type
Python for MATLAB Users

Indexing into NumPy arrays

print(arr)
[[2, 4, 8, 16, 32]]
  • Zero-based indexing
print(arr[2])
8
print(arr[0])
2
print(arr[-1])
32
Python for MATLAB Users

Visualizing data with Matplotlib

Example matplotlib visualization

Python for MATLAB Users

Using matplotlib

import matplotlib.pyplot as plt
# Create a new figure
plt.figure()

# Plot y as a function of x plt.plot(x, y)
# Set the x-label and y-label plt.xlabel('x') plt.ylabel('y')
# Be sure to show the plot! plt.show()

Python for MATLAB Users

Let's practice!

Python for MATLAB Users

Preparing Video For Download...