Complete the code to load a MATLAB file named 'data.mat' into a Python variable.
from scipy.io import [1] data = [1]('data.mat')
The loadmat function from scipy.io loads MATLAB files into Python.
Complete the code to save a Python dictionary 'my_data' to a MATLAB file named 'output.mat'.
from scipy.io import [1] my_data = {'a': [1, 2, 3]} [1]('output.mat', my_data)
The savemat function saves Python data to a MATLAB .mat file.
Fix the error in the code to correctly load a MATLAB file and access variable 'x'.
from scipy.io import loadmat data = loadmat('file.mat') x = data[1]
MATLAB variables are accessed from the loaded dictionary using square brackets and the variable name as a string.
Fill both blanks to save a dictionary with variable 'y' to 'result.mat' and then load it back.
from scipy.io import [1], [2] data_to_save = {'y': [4, 5, 6]} [1]('result.mat', data_to_save) loaded_data = [2]('result.mat')
Use savemat to save and loadmat to load MATLAB files.
Fill all three blanks to load 'data.mat', extract variable 'z', and save it to 'new_data.mat'.
from scipy.io import [1], [2] data = [1]('data.mat') z = data['z'] [2]('new_data.mat', {'z': z})
Use loadmat to load and savemat to save MATLAB files.