//
// MATLAB Compiler: 3.0
// Date: Sat Feb 28 16:17:54 2004
// Arguments: "-B" "macro_default" "-O" "all" "-O" "fold_scalar_mxarrays:on"
// "-O" "fold_non_scalar_mxarrays:on" "-O" "optimize_integer_for_loops:on" "-O"
// "array_indexing:on" "-O" "optimize_conditionals:on" "-M" "-silentsetup" "-d"
// "G:/MATLAB/work/Fourier/src" "-B" "cppsglcom:Fourier,Fourier,1.0" "-B"
// "csglcom:Fourier,Fourier,1.0" "-B" "sgl" "-m" "-W" "main" "-L" "C" "-t" "-T"
// "link:exe" "-h" "libmmfile.mlib" "-W" "mainhg" "libmwsglm.mlib" "-t" "-W"
// "comhg:Fourier,Fourier,1.0" "-T" "link:lib" "-h" "libmmfile.mlib" "-i" "-L"
// "cpp" "-i" "G:/MATLAB/work/AddNoise.m" "G:/MATLAB/work/PowerSpectrum.m"
//
#include "powerspectrum.hpp"
#include "libmatlbm.hpp"
#include "subplot.hpp"
#include "title.hpp"
#include "xlabel.hpp"
extern mwArray y;
static mwArray _mxarray0_ = mclInitializeDoubleVector(0, 0, (double *)NULL);
static mwArray _mxarray1_ = mclInitializeDouble(1000.0);
static mwArray _mxarray2_ = mclInitializeDouble(0.0);
static mwArray _mxarray3_ = mclInitializeDouble(1.0);
static mwArray _mxarray4_ = mclInitializeDouble(256.0);
static mwArray _mxarray5_ = mclInitializeDouble(512.0);
static mwArray _mxarray6_ = mclInitializeDouble(212.0);
static mwArray _mxarray7_ = mclInitializeDouble(257.0);
static mxChar _array9_[22] = { 'F', 'r', 'e', 'q', 'u', 'e', 'n', 'c',
'y', ' ', 'c', 'o', 'n', 't', 'e', 'n',
't', ' ', 'o', 'f', ' ', 'y' };
static mwArray _mxarray8_ = mclInitializeString(22, _array9_);
static mxChar _array11_[14] = { 'f', 'r', 'e', 'q', 'u', 'e', 'n',
'c', 'y', ' ', '(', 'H', 'z', ')' };
static mwArray _mxarray10_ = mclInitializeString(14, _array11_);
void InitializeModule_powerspectrum() {
}
void TerminateModule_powerspectrum() {
}
static mwArray Mpowerspectrum(int nargout_);
_mexLocalFunctionTable _local_function_table_powerspectrum
= { 0, (mexFunctionTableEntry *)NULL };
//
// The function "powerspectrum" contains the normal interface for the
// "powerspectrum" M-function from file "g:\matlab\work\powerspectrum.m" (lines
// 1-17). This function processes any input arguments and passes them to the
// implementation version of the function, appearing above.
//
mwArray powerspectrum() {
int nargout = 1;
mwArray m = mwArray::UNDEFINED;
m = Mpowerspectrum(nargout);
return m;
}
//
// The function "mlxPowerspectrum" contains the feval interface for the
// "powerspectrum" M-function from file "g:\matlab\work\powerspectrum.m" (lines
// 1-17). The feval function calls the implementation version of powerspectrum
// through this function. This function processes any input arguments and
// passes them to the implementation version of the function, appearing above.
//
void mlxPowerspectrum(int nlhs, mxArray * plhs[], int nrhs, mxArray * prhs[]) {
MW_BEGIN_MLX();
{
mwArray mplhs[1];
mclCppUndefineArrays(1, mplhs);
if (nlhs > 1) {
error(
mwVarargin(
mwArray(
"Run-time Error: File: powerspectrum Line: 1 Column"
": 1 The function \"powerspectrum\" was called with"
" more than the declared number of outputs (1).")));
}
if (nrhs > 0) {
error(
mwVarargin(
mwArray(
"Run-time Error: File: powerspectrum Line: 1 Column"
": 1 The function \"powerspectrum\" was called with"
" more than the declared number of inputs (0).")));
}
mplhs[0] = Mpowerspectrum(nlhs);
plhs[0] = mplhs[0].FreezeData();
}
MW_END_MLX();
}
//
// The function "Mpowerspectrum" is the implementation version of the
// "powerspectrum" M-function from file "g:\matlab\work\powerspectrum.m" (lines
// 1-17). It contains the actual compiled code for that M-function. It is a
// static function and must only be called from one of the interface functions,
// appearing below.
//
//
// function [m]=PowerSpectrum()
//
static mwArray Mpowerspectrum(int nargout_) {
mwLocalFunctionTable save_local_function_table_
= &_local_function_table_powerspectrum;
mwArray m = mwArray::UNDEFINED;
mwArray Pyy = mwArray::UNDEFINED;
mwArray Y = mwArray::UNDEFINED;
mwArray f = mwArray::UNDEFINED;
mwArray ans = mwArray::UNDEFINED;
//
// global x; %Original Signal
// global y; %Noisy Signal
//
// if (isempty(y))
//
if (tobool(isempty(mwVv(y, "y")))) {
//
// m = [];
//
m = _mxarray0_;
//
// return;
//
goto return_;
//
// end
//
}
//
//
// f = 1000*(0:256)/512;
//
f = _mxarray1_ * colon(_mxarray2_, _mxarray3_, _mxarray4_) / _mxarray5_;
//
// Y = fft(y,512);
//
Y = fft(mwVv(y, "y"), _mxarray5_);
//
// Pyy = Y.* conj(Y) / 512;
//
Pyy = times(mwVv(Y, "Y"), conj(mwVv(Y, "Y"))) / _mxarray5_;
//
// subplot(212)
//
ans.EqPrintAns(Nsubplot(0, _mxarray6_));
//
// plot(f,Pyy(1:257))
//
ans.EqPrintAns(
Nplot(
0,
mwVarargin(
mwVv(f, "f"),
mclArrayRef(mwVv(Pyy, "Pyy"), colon(_mxarray3_, _mxarray7_)))));
//
// title('Frequency content of y')
//
ans.EqPrintAns(Ntitle(0, _mxarray8_, mwVarargin()));
//
// xlabel('frequency (Hz)')
//
ans.EqPrintAns(Nxlabel(0, _mxarray10_, mwVarargin()));
//
// m=Pyy;
//
m = mwVv(Pyy, "Pyy");
return_:
mwValidateOutput(m, 1, nargout_, "m", "powerspectrum");
return m;
}