from
CefSplitter
by Ben Witvliet
CEF 2.0 multiscan splitter (ITU-R SM.1809)
|
| [err,err_msg]=CefSplitter(filename,datadir);
|
%------------------------------------------------------------------------%
% Program : CEF 2.0 SPLITTER %
%------------------------------------------------------------------------%
% Purpose : To split a measurement data file in the ITU recommended %
% "Common Exchange Format V2.0" that contains N frequency %
% scans into N independent files of the same CEF 2.0 format.%
% %
% Each file now contains one frequency scan and the header %
% information is adapted accordingly. %
% %
%------------------------------------------------------------------------%
% MatLab code version: 7.1 %
%------------------------------------------------------------------------%
% External functions used: Cef2Mat (v1.06) %
%------------------------------------------------------------------------%
% Creation / modification history: %
% 2008-08-25 - v1.00 - B.A.Witvliet - creation %
%------------------------------------------------------------------------%
% Conventions: %
% - Every new author adds to the modification history, but does never %
% erase names of earlier contributors. %
% - Arrays start with a capitol letter, single variables and single %
% variables don't. %
% - Main program names are all capitals, functions names only start %
% with a capital. %
% - Subprograms are always functions, not scripts. %
% - Global variables are avoided. %
%------------------------------------------------------------------------%
function [err,err_msg]=CefSplitter(filename,datadir);
% ------------------
% ERROR MESSAGES
% ------------------
% err err_msg
% 0 OK
% 0 Single scan file, no splitting performed
% 1 File retrieval error (No such file)
% 2 No CEF 2.0 file
% 3 CEF file header could not be read
% 4 CEF file body could not be read
% 5 Filename should be specified without extension
% ----------------------------------
% LOAD FILE INTO WORKSPACE
% ----------------------------------
[Header,Data,err,err_msg] = Cef2Mat_v1_06(filename,datadir);
% ----------------------------------
% HOW MANY SCANS IN FILE?
% ----------------------------------
n=size(Data.Level,3);
if n==1
err=0; err_msg='Single scan CEF 2.0 file, no splitting performed';
return;
end;
% ------------
% REDUCE TO N SINGLE SCAN MAT-FILES
% ------------
% - Retain the original multiscan data -
Header0=Header;
Data0=Data;
% - Go through all individual scans one by one -
for scannr=1:n
% - Reduce header to a single scan header
Header.FreqStart =Header0.FreqStart(scannr);
Header.FreqStop =Header0.FreqStop(scannr);
Header.AntennaType =Header0.AntennaType(scannr);
Header.FilterBandwidth=Header0.FilterBandwidth(scannr);
Header.DataPoints =Header0.DataPoints(scannr);
Header.Multiscan ='N';
% - Reduce data set to a single scan
Data.Level=Data0.Level(:,:,scannr);
% - Create filename with full path info - plus a scan number
fullname=[datadir '/' filename '_' num2str(scannr) '.mat'];
% - Save the single scan file -
save(fullname,'Header','Data');
end;
|
|
Contact us at files@mathworks.com