function [X] = GetSignalFromComponents( realIn, imagIn, w, intFlg, polarFlg ) % Returns the signal represented in the % .. specified source text files.which should be comma- or tab-delimited. % w is the common width (horizontal dimension) of the source arrays. % intFlg: 0 => input values are floats, comma- or tab-delimited. % 1 => input values are integers, comma- or tab-delimited. % 2 => (Reserved) % 3 => input is a binary stream % polarFlg: 0 => normal operation; % 1 => If 2 input files, then they contain angle, magnitude. % If 1 input file, then it contains magnitude (same as Real). % (This maintains consistency with Matlab's syntax.) % % 18 Dec 2008 - D.Bozarth, SSU Engineering Science % 12 Jan 2009 - Allow empty second parameter. % 13 Jan 2009 - Add polarFlg. % 14 Jan 2009 - Fix bug in my usage of pol2cart. % 27 Jan 2009 - Enable binary file input. % switch intFlg case 0 format = '%f%*c'; case 1 format = '%d%*c'; case 3 format = 'single'; otherwise X = []; return ; end fid = fopen(realIn, 'r'); if intFlg ~= 3 re = fscanf( fid, format, [w, inf] )'; else [reIn, nRead] = fread( fid, format ); re = VectorToMatrix( reIn', w ); end fclose(fid); if isequal(imagIn, '') sz = size( re ); h = sz(1); im = zeros( h, w ); polarFlg = 0; % In this case, treat the one file as Real. else fid = fopen(imagIn, 'r'); if intFlg ~= 3 im = fscanf( fid, format, [w, inf] )'; else [imIn, nRead] = fread( fid, format ); im = VectorToMatrix( imIn', w ); end end if polarFlg [re, im] = pol2cart(re, im); end X = re + i*im; % % end script