function eu = convertprr(prr, cfl) % CONVERTPRR - convert prr data from volts to engineering units % % Use as: eu = convertprr(prr, cfl) % % Inputs: prr = prr data structure in voltages (from READPRR) % cfl = Calibration data structure (from READCFL) % % Output: eu = column oriented data of prr data converted to engineering units % Brian Schlining % 27 Jan 2000 %================== % Process the data %================== numCpu = length(prr); if numCpu ~= cfl.numCpu error(sprintf('Number of CPUs mismatch.\nData file contains %i instruments.\nConfig file specifies %i instruments\n', numCpu, cfl.numCpu)); end [r c] = size(prr(1).volts); eu = ones(r, cfl.numChannel)*NaN; % Types 1 - 4: value = (volts - c) / b (a is unused) % Type 5: value = a + (b * volts) + (c * volts^2) % Type 6: value = a * (volts - c) / b % Type 7: value = a * b * (volts - c) for n = 1:cfl.numChannel volts = prr(cfl.info(n).tag + 1).volts(:, cfl.info(n).address); % Get the data in volts switch cfl.info(n).kind case 1 eu(:,n) = (volts - cfl.info(n).offset)/cfl.info(n).scale; case 2 eu(:,n) = (volts - cfl.info(n).offset)/cfl.info(n).scale; case 3 eu(:,n) = (volts - cfl.info(n).offset)/cfl.info(n).scale; case 4 eu(:,n) = (volts - cfl.info(n).offset)/cfl.info(n).scale; case 5 eu(:,n) = cfl.info(n).offset + (cfl.info(n).scale * volts) + (cfl.info(n).secondScale * volts); case 6 eu(:,n) = cfl.info(n).scale * (volts - cfl.info(n).offset) / cfl.info(n).secondScale; case 7 eu(:,n) = cfl.info(n).scale * cfl.info(n).secondScale * (volts - cfl.info(n).offset); end end