Matlab coder C conversion of an fft

1 visualizzazione (ultimi 30 giorni)
Can someone give me an example of what an fft should look like within a coder converted c code snippet? I am aware that the documentation says that fft is coder compatible, but I have not yet obtained successful results. What I end up receiving from coder is simply a copy of the input data. any help would be welcome. An example of what I have been testing is below.
function anFFT= fft_soundfile(input)
anFFT = input;
%do fft
X = abs(fft(input,1024));
%fft end
holder = X(1);
%data = abs(y)
end
What I am getting is as follows
/*
* Academic License - for use in teaching, academic research, and meeting
* course requirements at degree granting institutions only. Not for
* government, commercial, or other organizational use.
*
* anFFT.c
*
* Code generation for function 'anFFT'
*
*/
/* Include files */
#include "rt_nonfinite.h"
#include "anFFT.h"
/* Function Definitions */
void anFFT(const double input[27387], double b_anFFT[27387])
{
memcpy(&b_anFFT[0], &input[0], 27387U * sizeof(double));
/* do fft */
/* fft end */
/* data = abs(y) */
}
/* End of code generation (anFFT.c) */
This doesn't seem to be generating an fft. Can anyone help with this?

Risposta accettata

Walter Roberson
Walter Roberson il 12 Giu 2017
You have
function anFFT= fft_soundfile(input)
anFFT = input;
so your output is a copy of your input. Nothing you do later in your code affects the output. Everything after that point is optimized away.
  1 Commento
Tommy Owens
Tommy Owens il 12 Giu 2017
Thank you, as you can probably tell with this mistake; I am new to using MATLAB. That easily fixed my problem.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su MATLAB Coder in Help Center e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by