Arrays & plotting

Python för MATLAB-användare

Justin Kiggins

Product Manager

NumPy-arrays

  • Arrays = matriser
  • Arrays kan vara flerdimensionella
  • Varje element har samma typ
Python för MATLAB-användare

Indexering i NumPy-arrays

print(arr)
[[2, 4, 8, 16, 32]]
  • Nollbaserad indexering
print(arr[2])
8
print(arr[0])
2
print(arr[-1])
32
Python för MATLAB-användare

Visualisera data med Matplotlib

Exempel på matplotlib-visualisering

Python för MATLAB-användare

Använda 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 för MATLAB-användare

Nu kör vi en övning!

Python för MATLAB-användare

Preparing Video For Download...