help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Fwd: Want to know how to inluce octave fft lib in my Qt program


From: Prasanth N P
Subject: Fwd: Want to know how to inluce octave fft lib in my Qt program
Date: Thu, 24 Oct 2013 14:35:23 +0530



On Tue, Oct 22, 2013 at 4:33 PM, c. <address@hidden> wrote:

On 22 Oct 2013, at 12:17, Prasanth N P <address@hidden> wrote:

> Ok it work fine, but actually I just want the absolute value of those result.
>
>
>
>   octave_value_list output = feval ("fft", input, 1);
>
>   octave_value_list final_output = feval ("abs", output, 1);
>
>   ColumnVector output_vector = final_output(0).column_vector_value ();
> Is this the right method?

yes, if you want to do it through the Octave interpreter that is the correct approach,
otherwise you cajust do:

  ColumnVector output_vector = output(0).complex_column_vector_value ().abs ();


> How can I study these octave datatypes? Is any tutorial avialable for this octave c++ API?

there are some basic examples in the manual

  http://www.gnu.org/software/octave/doc/interpreter/Oct_002dFiles.html#Oct_002dFiles
  http://www.gnu.org/software/octave/doc/interpreter/Standalone-Programs.html#Standalone-Programs

and this presentation:

  http://wiki.octave.org/wiki/images/b/b0/Slides_octconf_gdf_jgh.pdf

but, as Octave is Free software and teherfore you are granted the freedom to study the sources,
the best option is to look at the code directly:

  http://hg.savannah.gnu.org/hgweb/octave/file/5b0036d89d4a

or through Doxygen

  http://octave.sourceforge.net/doxygen/html/index.html
  http://octave.sourceforge.net/doxygen/html/d3/de3/classComplexColumnVector.html


HTH,
c.

Hi,
The result set is completely different from that produced by octave prompt. Is this is the mistake of incorrect data extraction?


In octave prompt, my program is

load 'buffer'
setenv ("GNUTERM", "x11")
l=1024;
v=fft(buffer,l);
V = abs(v);
save output V;


will produce output


 29836655360
 7194618843.804271
 31222458039.80829
 6504667191.029741
 32288941967.04408
 9843961135.068363
 30983143293.79837
 7611290380.697447
 4861098750.903645
 3324109517.901031
 7207271566.692511
 3908976136.391438
 6415257024.785824
 etc.....



and the same input in c++,

  FILE *fp;

  fp = fopen("buffer","r");
  if (fp == NULL)
  return 0;
  
  for (ucI=0; ucI< 1024; ucI++)
    fscanf(fp, "%d\n", input_vector.fortran_vec () + ucI);

  fclose(fp);
  
  
  
  octave_value_list input;
  input(0) = input_vector;

  octave_value_list output = feval ("fft", input, 1);  
  octave_value_list final_output = feval ("abs", output, 1);
    
   
  ColumnVector output_vector = final_output(0).column_vector_value ();

  for (ucI=0; ucI< 1024; ucI++)
printf("%d\n",output_vector.fortran_vec () [ucI]);



will produce


-228115712
-2036061617
-41838449
2021575525
559518313
-452798453
994969983
610738633
2046297242
-430100987
-2078919967
567105869
617583034
288730045
etc...

What to do?




reply via email to

[Prev in Thread] Current Thread [Next in Thread]