[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How do you pass two Octave functions to an .oct function?
From: |
babelproofreader |
Subject: |
Re: How do you pass two Octave functions to an .oct function? |
Date: |
Mon, 26 Oct 2009 05:25:44 -0700 (PDT) |
>...it modifies the value - the output is not the same as the input.
How so? When I plot the input against the output the two plots are
identical.
>Have you tried printing out the result in each stage and comparing it to
the correct
value from the m-code?
I compiled the code in stages and so I am sure that it is the filter code
that is the problem. The code without the filtering, i.e.
#include <octave/oct.h>
#include <octave/dColVector.h>
#include <octave/parse.h>
DEFUN_DLD (pass3, args, , "Help String")
{
octave_value retval;
ColumnVector detrend_input = args(0).column_vector_value ();
ColumnVector detrend_output(detrend_input);
double intercept = detrend_input(0);
double slope = ( detrend_input( detrend_input.length () - 1 ) - intercept
) / ( detrend_input.length () - 1 );
octave_value_list fft_result;
ComplexColumnVector freq_rep;
octave_value_list ifft_result;
octave_value_list real_result;
ColumnVector real_result_rep;
ColumnVector retrended_real_result(detrend_input);
for (octave_idx_type ii (0); ii<detrend_input.length (); ii++)
{
detrend_output(ii) = detrend_input(ii) - intercept - (ii) * slope;
}
fft_result = feval ("fft", octave_value (detrend_output), 1);
freq_rep = fft_result (0).complex_column_vector_value ();
ifft_result = feval ("ifft", octave_value (freq_rep), 1);
real_result = feval ("real", ifft_result, 1);
real_result_rep = real_result (0).column_vector_value ();
for (octave_idx_type ii (0); ii<detrend_input.length (); ii++)
{
retrended_real_result(ii) = real_result_rep(ii) + intercept + (ii) *
slope;
}
retval = retrended_real_result;
return retval;
}
works OK.
--
View this message in context:
http://www.nabble.com/How-do-you-pass-two-Octave-functions-to-an-.oct-function--tp25870717p26058829.html
Sent from the Octave - General mailing list archive at Nabble.com.
- Re: How do you pass two Octave functions to an .oct function?, (continued)
- Re: How do you pass two Octave functions to an .oct function?, babelproofreader, 2009/10/15
- Re: How do you pass two Octave functions to an .oct function?, Jaroslav Hajek, 2009/10/16
- Re: How do you pass two Octave functions to an .oct function?, babelproofreader, 2009/10/16
- Re: How do you pass two Octave functions to an .oct function?, David Grundberg, 2009/10/18
- Re: How do you pass two Octave functions to an .oct function?, babelproofreader, 2009/10/20
- Re: How do you pass two Octave functions to an .oct function?, Jaroslav Hajek, 2009/10/20
- Re: How do you pass two Octave functions to an .oct function?, babelproofreader, 2009/10/21
- Re: How do you pass two Octave functions to an .oct function?, Jaroslav Hajek, 2009/10/22
- Re: How do you pass two Octave functions to an .oct function?, babelproofreader, 2009/10/25
- Re: How do you pass two Octave functions to an .oct function?, David Grundberg, 2009/10/25
- Re: How do you pass two Octave functions to an .oct function?,
babelproofreader <=
- Re: How do you pass two Octave functions to an .oct function?, babelproofreader, 2009/10/29