import numpy as np
# Create a 3x4 matrix with random numbers
matrix = np.random.randn(3, 4)
print("Original Matrix:")
print(matrix)
# Extract negative numbers into a one-dimensional array
negative_numbers = matrix[matrix < 0]
print("\nNegative Numbers Array:")
print(negative_numbers)
In this code, the np.random.randn(3, 4) function generates a 3x4 matrix with random numbers drawn from a standard normal distribution. The condition matrix < 0 creates a boolean mask indicating which elements of the matrix are negative, and then indexing the matrix with this condition extracts the negative numbers.