Complete the code to read data from a file named 'data.txt'.
fileID = fopen('data.txt', '[1]');
Use 'r' to open a file for reading in MATLAB.
Complete the code to write the variable 'data' to a file.
fileID = fopen('output.txt', '[1]');
Use 'w' to open a file for writing, which creates or overwrites the file.
Fix the error in the code to properly close the file after reading.
fileID = fopen('data.txt', 'r'); data = fscanf(fileID, '%f'); [1](fileID);
Use fclose(fileID) to close the file and free system resources.
Fill both blanks to read numeric data from a file and store it in 'data'.
fileID = fopen('numbers.txt', '[1]'); data = fscanf(fileID, '[2]'); fclose(fileID);
Open the file for reading with 'r' and use '%f' to read floating-point numbers.
Fill all three blanks to write a matrix to a file with formatted output.
fileID = fopen('matrix.txt', '[1]'); for i = 1:size(matrix, 1) fprintf(fileID, [2], matrix(i, :)); end fclose([3]);
Open the file for writing with 'w', use '%f %f %f\n' to format floats, and close with fclose(fileID).
