필터 지우기
필터 지우기

Saving and reloading a table

조회 수: 62 (최근 30일)
Timothy
Timothy 2023년 8월 18일
답변: Image Analyst 2023년 8월 18일
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.

답변 (1개)

Image Analyst
Image Analyst 2023년 8월 18일
That should work. You'll need to show us how you actually saved it with the save function.
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;

카테고리

Help CenterFile Exchange에서 Text Files에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by