Error using legacy_code (doubleIt Example)

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

 Akzeptierte Antwort

Kaustubha Govind
Kaustubha Govind am 20 Mai 2013

1 Stimme

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 Kommentar

Alexander
Alexander am 20 Mai 2013
Bearbeitet: Alexander am 20 Mai 2013
Thank you.
I've observed this too, later. ;)
Regards, Alex

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by