
From:  Prasanth N P 
Subject:  Re: Want to know how to inluce octave fft lib in my Qt program 
Date:  Mon, 21 Oct 2013 16:16:22 +0530 
On Mon, Oct 21, 2013 at 3:52 PM, c. <address@hidden> wrote:Hi,
On 21 Oct 2013, at 12:08, Prasanth N P <address@hidden> wrote:
> Ys, now I got what is top posting. Is this is the right method?
>
>
>
> I have a set of samples in an array and want to do the fft function and want to collect back to an array. This is my need. How can I implement this? I am tried to as given below.
>
> fp = fopen("buffer","r");
> if (fp == NULL)
> return 0;
>
> for (ucI=0;ucI< 1024;ucI++)
> fscanf(fp,"%d\n",&InData[ucI]);
>
>
> octave_value_list input;
>
>
> for (int i = 0; i < 1024; i++)
> {
> input (i) = InData[i];
>
> }
>
> octave_value_list output = feval ("fft", input, 1024);
>
>
> Is this is the right method? How can I collect the output to an array?
No, it isn't, what you are doing now is equivalent to calling fft in the interpreter with 1024 scalar inputs equal to the entries of your vector.
and you are expecting fft to return 1024 outputs while you will get only one vector output ...
The following example should point you in the right direction (beware, this is untested code):ColumnVector input_vector (1024, 0.0);
fp = fopen("buffer","r");
if (fp == NULL)
return 0;
for (int ucI=0; ucI< 1024; ucI++)
fscanf(fp, "%d\n", input_vector.fortran_vec () + ucI);
octave_value_list input;
input(0) = input_vector;
octave_value_list output = feval ("fft", input, 1);
ColumnVector output_vector = output(0).column_vector_value ();
for (int ucI=0; ucI< 1024; ucI++)
std::cout << output_vector.fortran_vec ()[ucI];
HTH,
c.
[Prev in Thread]  Current Thread  [Next in Thread] 