import matlab.engine
def multiply_matrices_using_matlab(A, B):
# Start MATLAB engine
eng = matlab.engine.start_matlab()
# Convert Python list to MATLAB array
A_matlab = matlab.double(A.tolist())
B_matlab = matlab.double(B.tolist())
# Call MATLAB function
result_matlab = eng.multiplyMatrices(A_matlab, B_matlab)
# Stop the MATLAB engine
eng.quit()
# Convert MATLAB result back to Python format
result_python = np.array(result_matlab)
return result_python
if __name__ == "__main__":
import numpy as np
A = np.random.rand(100, 100)
B = np.random.rand(100, 100)
result = multiply_matrices_using_matlab(A, B)
print(result)