Hi all,
I am trying to read on matlab several .MDF files. All of them are exported with the some tool and for some reasons, some of them are unsorted. I need to know which files are unsorted. Is there any way to do that?
Here is my code. If a file is unsorted I get an error when I read the file, so I added the two lines which sort the files (the two under comment), but in that case, if the file is sorted, I get an error at the mdfSort function. By knowing which files are unsorted, I can solve the problem with a If-statement.
for iFile=1:length(MDFFile) Duration=-1; % sortedPath = mdfSort([MDFFolder MDFFile(iFile).name],'SortedMDFFile.mdf');
% mdfObj = mdf('SortedMDFFile.mf4');
mdfObj = mdf([MDFFolder MDFFile(iFile).name]); if isempty(mdfObj.ChannelNames)==0 chlist = channelList(mdfObj); chlistS=table2struct(chlist); chlistName=convertStringsToChars([chlistS.ChannelName]); for iSig=1:length(Signals2Load) iCh=find(strcmp(chlistName,Signals2Load{iSig})); if isempty(iCh)==0 data = read(mdfObj,chlistS(min(iCh)).ChannelGroupNumber,Signals2Load{iSig}); if Duration<0 Duration=seconds(floor(max(data.Time))); CanData(iFile).Time=[0:TS:Duration]; end CanData(iFile).(Signals2Load{iSig})=pchip(seconds(data.Time),data.(Signals2Load{iSig}),CanData(iFile).Time); end end else warning(['Problems in loading ' MDFFile(iFile).name]) endend
Best Answer