About Site Map Submit Contact Us Log in | Create an account
Create an account Log In
Average Rating
User Rating:
Visitors Rating:
My rating:

Write review
See full specifications

scripts default iconAverage Across Frequencies (Scripts) Publisher's description

This sounds at first like a trivial task

This sounds at first like a trivial task, but in practice took something that works correctly and faster for larger datasets (i.e. without using a simple find or related statement each time within a for loop). Thus I am submitting this here in case it might the time of anyone else with similar needs who comes across this.

Help comments for the function:
%function [OutVals fout]=AvgAcrossFreqs(InVals,fraw,fstep,fk,f0cut,CalcType)
% Will Avg InVals across the freq vals give in fraw into the output
% frequency bins separated by fstep with range given by fk, and initial bin
% determined by f0cut.
% This could of course be applied generally to average any one value over
% another, but was written with the intention of averaging coherence or
% spectral power values across frequencies in a data format with multiple
% repetitions (for example multiple subjects or experiment sessions).
% Inputs
% InVals: The values to be averaged across. Could be a single
% numeric array, of dimension NReps x nRawf, or could be
% a 1D cell array of any number of such a numeric array.
% fraw: A 1D vector of length nRawf (matching the 2nd
% dimension of numeric arrays of InVals) indicating the
% input freequency correspnding to each val of InVals.
% Assuemd to be in Hz- though any freq unit could be used
% if the other inputs are consistent with that unit.
% fstep: The frequency resolution (in Hz) of the output that the
% InVals are averaged into. Defaults to 1/8.
% fk: A 1x2 or 2x1 vector indicating the output frequency
% range to use. Defaults to [0 100].
% f0cut: Indicates the upper cutoff frequency used for the
% first bin. ... so the first output bin frequency will
% avg InVals from fk(1) up to f0cut, and each output bin
% will increase in fstep steps from there. Defaults to
% fstep/2.
% CalcType: Indicates how to do the averaging. This can be a
% scalar, or if InVals is a cell array, a 1D vector with
% each value corresponding to each cell in InVals. This
% can also be a scalar if InVals is a cell array, in
% which case the value will apply to all cells of InVals.
% case:
% 1 corresponds to a basic nanmean. (for coh mags, abs
% vals should be done to the input BEFORE CALLING
% this function.) (This is the Default)
% 2: any function.
% 3: sum function
% 4: angle of the sum across frequencies
% 5: angle of the sum across repetitions and
% frequencies. Note that this affects the size of
% OutVals, by forcing it to have 1 row/rep.
% Outputs
% OutVals: A numeric array or CellArray corresponding to InVals.
% Each numeric array will have dimensions nReps x nfout.
% (Or possible 1 x nfout if CalcType is set to 5).
% fout: The output frequencies, corresponding to the center
% frequency of each frequency bin in OutVals.
% Matthew Nelson 2010
% nelsonmj@caltech.edu http://www.its.caltech.edu/~nelsonmj/

System Requirements:

MATLAB 7.10 (2010a)
Program Release Status: New Release
Program Install Support: Install and Uninstall

Average Across Frequencies (Scripts) Tags:

Click on a tag to find related softwares

Is Average Across Frequencies (Scripts) your software?

Manage your software

Most Popular

scripts default icon ASK, OOK, FSK, BPSK, QPSK, 8PSK modulation 1.1
ASK, OOK, FSK, BPSK, QPSK, 8PSK modulation contain several functions for digital modulation simulation
scripts default icon Simulink Communication Labs 1.1
Simulink Communication Labs allows you to learn communication systems in greater depth.
scripts default icon M-QAM modulation and demodulation 1.1
M-QAM modulation and demodulation is the QAM modulation and demodulation tech.
scripts default icon LZW Compression/Decompression 1.1
LZW Compression/Decompression - Updated LZW compressor and decompressor with reasonable performance
scripts default icon InSPIRE utility to plot a 2D displacement field (Scripts) 1.0
This program plots the deformation field (displace vectors) contained in vector.txt.