Error using legacy_code (doubleIt Example)

조회 수: 3 (최근 30일)
Alexander
Alexander 2013년 5월 18일
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

채택된 답변

Kaustubha Govind
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
Alexander
Alexander 2013년 5월 20일
편집: Alexander 2013년 5월 20일
Thank you.
I've observed this too, later. ;)
Regards, Alex

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Alexander
Alexander 2013년 5월 19일
#push

카테고리

Help CenterFile Exchange에서 C Shared Library Integration에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by