From: <cd...@us...> - 2012-08-07 05:55:15
|
Revision: 10832 http://octave.svn.sourceforge.net/octave/?rev=10832&view=rev Author: cdf Date: 2012-08-07 05:55:09 +0000 (Tue, 07 Aug 2012) Log Message: ----------- fix test syntax Modified Paths: -------------- trunk/octave-forge/extra/lssa/inst/lombnormcoeff.m Modified: trunk/octave-forge/extra/lssa/inst/lombnormcoeff.m =================================================================== --- trunk/octave-forge/extra/lssa/inst/lombnormcoeff.m 2012-08-05 23:05:36 UTC (rev 10831) +++ trunk/octave-forge/extra/lssa/inst/lombnormcoeff.m 2012-08-07 05:55:09 UTC (rev 10832) @@ -22,20 +22,19 @@ ## ## @end deftypefn -%!test -%!shared t, x, o, maxfreq; -%! maxfreq = 4 / ( 2 * pi ); -%! t = linspace(0,8); -%! x = ( 2.*sin(maxfreq.*t) + 3.*sin((3/4)*maxfreq.*t) - 0.5 .* sin((1/4)*maxfreq.*t) - 0.2 .* cos(maxfreq .* t) + cos((1/4)*maxfreq.*t)); -%! o = [ maxfreq , 3 / 4 * maxfreq , 1 / 4 * maxfreq ]; -%!assert( lombnormcoeff(t,x,o(1)),63.3294946603949,5e-10 ); -%!assert( lombnormcoeff(t,x,o(2)),73.2601360674868,5e-10 ); -%!assert( lombnormcoeff(t,x,o(3)),53.0799752083903,5e-10 ); - function coeff = lombnormcoeff(T,X,omega) tau = atan2( sum( sin( 2.*omega.*T)), sum(cos(2.*omega.*T))) / 2; coeff = ( ( sum ( X .* cos( omega .* T - tau ) ) .^ 2 ./ sum ( cos ( omega .* T - tau ) .^ 2 ) + sum ( X .* sin ( omega .* T - tau ) ) .^ 2 / sum ( sin ( omega .* T - tau ) .^ 2 ) ) / ( 2 * var(X) ) ); endfunction + +%!shared t, x, o, maxfreq +%! t = linspace(0,8); +%! maxfreq = 4 / ( 2 * pi ); +%! o = [ maxfreq , 3 / 4 * maxfreq , 1 / 4 * maxfreq ]; +%! x = ( 2.*sin(maxfreq.*t) + 3.*sin((3/4)*maxfreq.*t) - 0.5 .* sin((1/4)*maxfreq.*t) - 0.2 .* cos(maxfreq .* t) + cos((1/4)*maxfreq.*t)); +%!assert( lombnormcoeff(t,x,o(1)),63.3294946603949,5e-10 ); +%!assert( lombnormcoeff(t,x,o(2)),73.2601360674868,5e-10 ); +%!assert( lombnormcoeff(t,x,o(3)),53.0799752083903,5e-10 ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cd...@us...> - 2012-08-07 06:03:51
|
Revision: 10833 http://octave.svn.sourceforge.net/octave/?rev=10833&view=rev Author: cdf Date: 2012-08-07 06:03:45 +0000 (Tue, 07 Aug 2012) Log Message: ----------- beautify test syntax Modified Paths: -------------- trunk/octave-forge/extra/lssa/inst/lombnormcoeff.m Modified: trunk/octave-forge/extra/lssa/inst/lombnormcoeff.m =================================================================== --- trunk/octave-forge/extra/lssa/inst/lombnormcoeff.m 2012-08-07 05:55:09 UTC (rev 10832) +++ trunk/octave-forge/extra/lssa/inst/lombnormcoeff.m 2012-08-07 06:03:45 UTC (rev 10833) @@ -31,10 +31,14 @@ endfunction %!shared t, x, o, maxfreq -%! t = linspace(0,8); -%! maxfreq = 4 / ( 2 * pi ); -%! o = [ maxfreq , 3 / 4 * maxfreq , 1 / 4 * maxfreq ]; -%! x = ( 2.*sin(maxfreq.*t) + 3.*sin((3/4)*maxfreq.*t) - 0.5 .* sin((1/4)*maxfreq.*t) - 0.2 .* cos(maxfreq .* t) + cos((1/4)*maxfreq.*t)); -%!assert( lombnormcoeff(t,x,o(1)),63.3294946603949,5e-10 ); -%!assert( lombnormcoeff(t,x,o(2)),73.2601360674868,5e-10 ); -%!assert( lombnormcoeff(t,x,o(3)),53.0799752083903,5e-10 ); +%! maxfreq = 4 / (2 * pi); +%! t = linspace (0, 8); +%! x = (2 .* sin (maxfreq .* t) + +%! 3 .* sin ((3/4) * maxfreq .* t) - +%! 0.5 .* sin((1/4) * maxfreq .* t) - +%! 0.2 .* cos (maxfreq .* t) + +%! cos ((1/4) * maxfreq .*t)); +%! o = [maxfreq , (3/4 * maxfreq) , (1/4 * maxfreq)]; +%!assert (lombnormcoeff (t,x,o(1)), 63.3294946603949, 5e-10); +%!assert (lombnormcoeff (t,x,o(2)), 73.2601360674868, 5e-10); +%!assert (lombnormcoeff (t,x,o(3)), 53.0799752083903, 5e-10); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cd...@us...> - 2012-08-07 06:08:51
|
Revision: 10834 http://octave.svn.sourceforge.net/octave/?rev=10834&view=rev Author: cdf Date: 2012-08-07 06:08:45 +0000 (Tue, 07 Aug 2012) Log Message: ----------- beautify code syntax in lombnormcoeff Modified Paths: -------------- trunk/octave-forge/extra/lssa/inst/lombnormcoeff.m Modified: trunk/octave-forge/extra/lssa/inst/lombnormcoeff.m =================================================================== --- trunk/octave-forge/extra/lssa/inst/lombnormcoeff.m 2012-08-07 06:03:45 UTC (rev 10833) +++ trunk/octave-forge/extra/lssa/inst/lombnormcoeff.m 2012-08-07 06:08:45 UTC (rev 10834) @@ -23,11 +23,13 @@ ## @end deftypefn -function coeff = lombnormcoeff(T,X,omega) -tau = atan2( sum( sin( 2.*omega.*T)), sum(cos(2.*omega.*T))) / 2; -coeff = ( ( sum ( X .* cos( omega .* T - tau ) ) .^ 2 ./ sum ( cos ( omega .* T - tau ) .^ 2 ) - + sum ( X .* sin ( omega .* T - tau ) ) .^ 2 / sum ( sin ( omega .* T - tau ) .^ 2 ) ) - / ( 2 * var(X) ) ); +function coeff = lombnormcoeff (T, X, omega) + +tau = atan2 (sum (sin (2 .* omega .*T)), sum (cos (2 .* omega .* T))) / 2; +coeff = ((sum (X .* cos (omega .* T - tau)) .^ 2 / sum (cos (omega .* T - tau) .^ 2) + + sum (X .* sin (omega .* T - tau)) .^ 2 / sum (sin (omega .* T - tau) .^ 2 )) / + (2 * var(X))); + endfunction %!shared t, x, o, maxfreq This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |