How can I use C code generated by Matlab coder?

2 次查看(过去 30 天)
I'm trying to use a simple function generated from matlab coder on my PIC MCU. The matlab function is:
function [c] = myMult(a)
b = [1,2,4;
7,1,2;
8,4,9];
c = a.*b;
And the generated C code is:
/*
* myMult.c
*
* Code generation for function 'myMult'
*
* C source code generated on: Wed Jul 17 10:22:38 2013
*
*/
/* Include files */
#include "myMult.h"
/* Function Definitions */
void myMult(real_T a, real_T c[9])
{
int32_T i0;
static const int8_T b[9] = { 1, 7, 8, 2, 1, 4, 4, 2, 9 };
/* Mult */
for (i0 = 0; i0 < 9; i0++) {
c[i0] = a * (real_T)b[i0];
}
}
/* End of code generation (myMult.c) */
+ some other header files
So, how can I work with function:
void myMult(real_T a, real_T c[9])
Shouldn't be return value instead of void? Shouldn't be between () only one, input value? I generated C code same way like in webinar MATLAB to C Made Easy.
Thank's for replies
Viktor

采纳的回答

Kaustubha Govind
Kaustubha Govind 2013-7-22
The second input argument is actually a pointer, if you notice that it's passed in as real_T c[9], which is equivalent to real_T *c. Essentially, you need to allocate memory for a real_T vector of 9 elements and pass it in by reference. The output is assigned to that same variable.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 MATLAB Coder 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by