Saving and reloading a table
69 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hello,
I created a livescript for data, and the result is a table. I open the live script and multiply several variables in the table in order to transform them into the necessary data. I then save the new table. Whenever I try to load it, however, the following occurs:
>> load('Tex.mat')
Error using load
Unable to read MAT-file C:\Users\(filelocation). File might be corrupt.
How do I save and access this table within MATLAB? Thank you.
0 comentarios
Respuestas (1)
Image Analyst
el 18 de Ag. de 2023
What I'd do is
%------------------------------------------------------------------------------------
% Save table.
folder = pwd; % Specify some folder where the output file will be saved to.
fullFileName = fullfile(folder, 'Tex.mat'); % Get the full path : folder plus name.
save(fullFileName, 'newTable'); % Save table "newTable" into a .mat file.
%------------------------------------------------------------------------------------
% Recall table.
if ~isfile(fullFileName) % Make sure file exists.
% Then the file was not found.
errorMessage = sprintf('ERROR: The file "%s" does not exist', fullFileName)
uiwait(errordlg(errorMessage));
return; % Bail out since file was not found.
end
% If we get here, the file exists. First, read the mat file into a structure.
s = load(fullFileName) % I like to leave the semicolon off so it prints all field names to the command window.
% Extract the newTable field of the structure into its own variable for convenience.
recalledTable = s.newTable;
0 comentarios
Ver también
Categorías
Más información sobre Text Files en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!