Cannot open matlab file

I have a .mat file supposedly containing a matrix [30720000x4 double] (values ​​from accelerometers). When I try to open this file using "Import Data" in Matlab, I get the following error:

Error using load
Can't read file F:\vibration_exp_2\GR_UB50n\bearing1\GR_UB50n_1_2.mat.

Error using load
Unknown text on line number 1 of ASCII file
F:\vibration_exp_2\GR_UB50n\bearing1\GR_UB50n_1_2.mat
"MATLAB".

Error in uiimport/runImportdata (line 456)
                    datastruct = load('-ascii', fileAbsolutePath);

Error in uiimport/gatherFilePreviewData (line 424)
        [datastruct, textDelimiter, headerLines]= runImportdata(fileAbsolutePath,
        type);

Error in uiimport (line 240)
[ctorPreviewText, ctorHeaderLines, ctorDelim] = ...

The file size is 921 MB, which is the same as my other files that open. I also tried to open the file using python, but did not succeed. Any suggestions? I am using MATLAB R2013b.


Additional Information:

How the file was created:

%% acquisition of vibration data
% input:
% sample rate in Hz (max. 51200 Hz, should be used as bearing 
% faults are high-frequent)
% time in seconds, stating the duration of the measurement 
% (e.g. 600 seconds = 10 minutes)
% filename for the file to be saved
%
% examples:
% data = DAQ(51200, 600, 'NF1_1.mat'); 
% data = DAQ(51200, 600, 'NF1_2.mat'); 
function data = DAQ(samplerate,time,filename) 

s = daq.createSession('ni'); % Creates the DAQ session
%%% Add the channels as accelerometer channels (meaning IEPE is turned on)
s.addAnalogInputChannel('cDAQ1Mod1','ai0','Accelerometer'); 
s.addAnalogInputChannel('cDAQ1Mod1','ai1','Accelerometer'); 
s.addAnalogInputChannel('cDAQ1Mod1','ai2','Accelerometer'); 
s.addAnalogInputChannel('cDAQ1Mod1','ai3','Accelerometer'); 
%s.addAnalogInputChannel('cDAQ1Mod2','ai0','Accelerometer'); 

s.Rate = samplerate;
s.NumberOfScans = samplerate*time; 
%%% Defining the Sensitivities in V/g
s.Channels(1).Sensitivity = 0.09478; %31965, top outer
s.Channels(2).Sensitivity = 0.09531; %31966, back outer
s.Channels(3).Sensitivity = 0.09275; %31964, top inner
s.Channels(4).Sensitivity = 0.09363; %31963, back inner

data = s.startForeground(); %Acquiring the data

save(filename, 'data');

Additional Information:

When I open the file with a simple text editor, I see many characters that do not make sense, but also in the first line:

MATLAB 5.0 MAT-FILE, Platform: PCWIN64, Created on: Thu Apr 30 16:29:07 2015


: : https://www.dropbox.com/s/r7mavil79j47xa2/GR_UB50n_1_2.mat?dl=0 921 .


EDIT:

?

, . , .

+4
3

, , , .

, .mat , . "" - , . MAT . , .mat.

, splitmat.m , , , , , , .

miCOMPRESSED, matlab, gzip. (, , "" .) , , .

. ".gz" , . , , . gzip, , ( ) , . , , , , . , .

, .gz , , , . , , MAT-File Format, 13f.

corrupted_file_id = fopen('corrupt.mat','r');
%% some header data
% can be skipped replacing this block with
% fread(id,132);

%header of .mat file
header_text = char(fread(corrupted_file_id,116,'char')');
subsystem_data_offset = fread(corrupted_file_id,8,'uint8');
version = fread(corrupted_file_id,1,'int16');
endian_indicator = char(fread(corrupted_file_id,2,'int8')');
data_type = fread(corrupted_file_id,4,'uint8'); 
%data_type is 15, so it is a compressed matlab array


%% save te content
data_size = fread(corrupted_file_id,1,'uint32');
gz_file_id = fopen('compressed_array.gz','w');
% first write a valid gzip head
fwrite(gz_file_id,hex2dec('1f8b080000000000'),'uint64',0,'b');

% then write the data sequentialy 
step = 1:1e3:data_size;% 1MB steps
for idx = step
fwrite(gz_file_id,fread(corrupted_file_id,1e3,'uint8'));
end
step = step(end):data_size;% 1B steps
for idx = step
    fwrite(gz_file_id,fread(corrupted_file_id,1,'uint8'));
end
fclose(gz_file_id);
fclose(corrupted_file_id);
+4
+1

(, ), , . Octave, .mat,

memory exhausted or requested size too large for range of Octave index type

To find out what's wrong, you may need to write a test program outside of MatLab, where you have more control over memory management. Examples are here , including instructions for creating them on your own platform. These standalone programs may not have the same memory problems. The program is matdgns.cspecifically designed to check files .matfor errors.

0
source

Source: https://habr.com/ru/post/1615762/


All Articles