function [freq,real,imag]=HPr(filename); % % Read in HP spectrum analyzer files for transfer functions saved using HP 3536A % and converted using 63x_mx.bat batch file from the /lifutil folder on Bob's Desktop % % freq = array of frequencies that data were measured at % real = real part of frequency response % imag = imaginary part of frequency response % % (Modified by Dave Bonfield from HPread.m, supplied by AJW.) % fid = fopen(filename,'r'); % % three header lines, which contain the # of data points: t1 = fgetl(fid); t2 = fgetl(fid); t3 = fgetl(fid); [q1 N q3 q4] = strread(t3,'%s%d%d%s'); % % now the frequency data; read until the next comment line: freq = fscanf(fid,'%f'); % now a comment line, also containing the # of data points: t4 = fgetl(fid); [q1 N q3 q4] = strread(t4,'%s%d%d%s'); % % now the real part of the frequency response: real = fscanf(fid,'%f', N); % % now the imaginary part of frequency response imag = fscanf(fid,'%f', N); % % close the file: fclose(fid); % return;