How can I load a .mat struct?
조회 수: 1 (최근 30일)
이전 댓글 표시
Hello community:
I use Matlab 2021a and when I try to load a .mat struct with these sentences load('linesStruct_1.mat') or load('linesStruct_1') I receive the following message:
Error using load
Unable to read MAT-file C:\ ... linesStruct_1.mat. Not a binary MAT-file. Try load -ASCII to
read as text.
Error in drawpoint_Algoritmo_Rename_Struct_Pendiente (line 5)
load('linesStruct_1.mat');
Could it be because I have saved the structures with a different name (lines in place of linesStruct_1.mat) than the image? Or maybe it has to do with the shortcut icons that appear in my folders?.

I remember this was not happening in other versions. I have been reading the many cases in which this occurs but I can not find a solution according to my situation. Any idea?
Thank you very much.
댓글 수: 0
채택된 답변
Walter Roberson
2021년 6월 26일
The file is not a .mat file. At the moment we do not know what it is. Experiment with
filename = 'linesStruct_1.mat';
if isunix()
filename = 'handel.mat';
end
[fid, msg] = fopen(filename, 'r');
if fid < 0
error('could not open file "%s" because "%s"', filename, msg);
end
bytes = fread(fid, [1 100], '*uint8');
fclose(fid)
fprintf('first part of file as text:\n');
fprintf('%s\n', char(bytes));
fprintf('\nas decimal: \n');
disp(bytes);
fprintf('\nas hex: \n');
fprintf('%02x ', bytes);
fprintf('\n');
The bit about isunix() is my substituting a different file for the purpose of demonstration here.
You are hoping to see the text version start with 'MATLAB 5.0' or 'MATLAB 7.3' . If you show us the three parts of the output we might be able to tell you what kind of file you actually have instead of a .mat file.
댓글 수: 7
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
