Error using legacy_code (doubleIt Example)
조회 수: 3 (최근 30일)
이전 댓글 표시
Hey there, ive got some problems. I was rebuilding the example "Integrate C Functions Using Legacy Code Tool" and got some errors after "legacy_code('sfcn_cmex_generate', def);".
Here is my code:
---
doubleIt.c:
#include "doubleIt.h"
double doubleIt(double inVal)
{
return(2*inVal);
}
---
doubleIt.h:
#ifndef DOUBLEIT_H
#define DOUBLEIT_H
double doubleIt(double inVal);
#endif
---
Matlabcode:
def = legacy_code('initialize')
def.SourceFiles = ('doubleIt.c');
def.HeaderFiles = ('doubleIt.h');
def.SFunctionName = 'ex_sfun_doubleit';
def.OutputFcnSpec = 'double y1 = doubleIt(double u1)';
legacy_code('sfcn_cmex_generate', def);
---
Errors after typing "legacy_code('sfcn_cmex_generate', def)":
Error using lct_pValidateStructure (line 44) The field "HeaderFiles" is of class "char" and must be of class "cell"
Error in C:\Program Files\MATLAB\R2013a\toolbox\simulink\simulink\+legacycode\@LCT\LCT.p>LCT.LCT (line 43)
Error in C:\Program Files\MATLAB\R2013a\toolbox\simulink\simulink\+legacycode\@LCT\legacyCodeImpl.p>iCreateLctObject (line 171)
Error in C:\Program Files\MATLAB\R2013a\toolbox\simulink\simulink\+legacycode\@LCT\legacyCodeImpl.p>legacyCodeImpl (line 52)
Error in legacy_code (line 87) [varargout{1:nargout}] = legacycode.LCT.legacyCodeImpl(action, varargin{1:end});
---
How do i fix it? :X
Regards, Alex
댓글 수: 0
채택된 답변
Kaustubha Govind
2013년 5월 20일
The documentation uses curly braces (which defines cell-arrays) to define the SourceFiles and HeaderFiles fields (you are using regular parentheses):
...
def.SourceFiles = {'doubleIt.c'};
def.HeaderFiles = {'doubleIt.h'};
...
추가 답변 (1개)
참고 항목
카테고리
Help Center 및 File Exchange에서 C Shared Library Integration에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!