How to test C code generated using MATLAB Coder

3 ビュー (過去 30 日間)
A R
A R 2020 年 3 月 20 日
Hi, I converted the code from matlab central https://in.mathworks.com/matlabcentral/fileexchange/6879-fast-walsh-hadamard-transform to C code using MATLAB Coder.
Now I need to test and compile this code.
/*
* File: fwt1d.c
*
* MATLAB Coder version : 2.6
* C/C++ source code generated on : 09-Mar-2020 22:05:51
*/
/* Include files */
#include "rt_nonfinite.h"
#include "fwt1d.h"
#include "fwt1d_emxutil.h"
/* Function Declarations */
static void bitrevorder(const double X_data[], const int X_size[2],
emxArray_real_T *R);
static int div_s32_floor(int numerator, int denominator);
/*
* The function implement the 1D sequency(Walsh)ordered
* fast Walsh-Hadamard transform,
* This algorithm is implemented in N log2 N additions and subtractions.
* Data sequence length should be an integer power of 2.
* Otherwise last elements will be truncated.
* The inverse transform is the same as the forward transform
* except for the multiplication factor N.
*
* Example:
* x=[1 2 1 1]
* y=fhtseq(x)
*
* Author: Gylson Thomas
* e-mail: gylson_thomas@yahoo.com
* Asst. Professor, Electrical and Electronics Engineering Dept.
* MES College of Engineering Kuttippuram,
* Kerala, India, February 2005.
* copyright 2007.
* Arguments : const double data_data[]
* const int data_size[2]
* emxArray_real_T *x
* Return Type : void
*/
void fwt1d(const double data_data[], const int data_size[2], emxArray_real_T *x)
{
int N;
double k1;
double k2;
double k3;
double fdbl;
int eint;
double L1;
int b_x;
int i3;
double i;
double j;
double temp1;
double temp2;
/* ------------------------------------------------------- */
/* 1D sequency(Walsh)ordered Fast Walsh-Hadamard Transform */
/* ------------------------------------------------------- */
bitrevorder(data_data, data_size, x);
N = x->size[1];
k1 = x->size[1];
k2 = 1.0;
k3 = (double)x->size[1] / 2.0;
if (x->size[1] == 0) {
fdbl = rtMinusInf;
} else {
fdbl = frexp(x->size[1], &eint);
if (fdbl == 0.5) {
fdbl = (double)eint - 1.0;
} else {
fdbl = log(fdbl) / 0.69314718055994529 + (double)eint;
}
}
for (eint = 0; eint < (int)fdbl; eint++) {
/* In-place iteration begins here */
L1 = 1.0;
for (b_x = 0; b_x < (int)k2; b_x++) {
for (i3 = 0; i3 < (int)k3; i3++) {
i = ((1.0 + (double)i3) + L1) - 1.0;
j = i + k3;
temp1 = x->data[(int)i - 1];
temp2 = x->data[(int)j - 1];
if ((1.0 + (double)b_x) - floor((1.0 + (double)b_x) / 2.0) * 2.0 == 0.0)
{
x->data[(int)i - 1] -= x->data[(int)j - 1];
x->data[(int)j - 1] = temp1 + temp2;
} else {
x->data[(int)i - 1] += x->data[(int)j - 1];
x->data[(int)j - 1] = temp1 - temp2;
}
}
L1 += k1;
}
k1 /= 2.0;
k2 *= 2.0;
k3 /= 2.0;
}
fdbl = 1.0 / (double)N;
eint = x->size[0] * x->size[1];
x->size[0] = 1;
emxEnsureCapacity((emxArray__common *)x, eint, (int)sizeof(double));
eint = x->size[0];
b_x = x->size[1];
b_x *= eint;
for (eint = 0; eint < b_x; eint++) {
x->data[eint] *= fdbl;
}
}
/*
* File trailer for fwt1d.c
*
* [EOF]
*/
My matlab function only contains 1 argument but the generated code has 3 function arguments.
void fwt1d(const double data_data[], const int data_size[2], emxArray_real_T *x)
  1. What is emxArray_real_T *x
  2. How to run this code in embedded application
  3. Can I test this code in MATLAB and how?

回答 (0 件)

カテゴリ

Find more on MATLAB Coder in Help Center and File Exchange

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by