errors seen
1.Expected either a logical, char, single, or double.
Found an mxArray. mxArrays are returned from calls to the MATLAB interpreter and are not supported inside expressions. They may be used on the right-hand side of assignments and as arguments to MATLAB calls.
Function 'Embedded MATLAB Function' (#18.268.269), line 9, column 4:
"G"
2.Undefined function or variable 'U'.
The first assignment to a local variable determines its class. Inputs, outputs, and parameters inherit their class from the model explorer.
Function 'Embedded MATLAB Function' (#18.282.283), line 10, column 10:
"U"
3.Errors occurred during parsing of Embedded MATLAB function 'Embedded
MATLAB Function'(#18)
4.Undefined function or variable 'U'.
The first assignment to a local variable determines its class. Inputs, outputs, and parameters inherit their class from the model explorer.
Function 'Embedded MATLAB Function' (#18.299.300), line 11, column 10:
"U"
Also embedded function block supports only a few matlab functions.I need to use it with real time workshop to run the real time application and hence c code must also be subsequently generated from this simulink block.
Hope some one has encountered a similar problem and would kindly respond.
Thank u
To get your code to work in simulation you need to have a look at the doc for the embedded MATLAB function block; inparticular what the code needs to look like for you to call functions not intinsically supported by the eml block.
See
>> doc eml.extrinsic
for the specifics.
To get it to work with Real-Time Workshop you will need to find a C-code equivalent of the functions not intrinsicly supported by the eml block.
The MathWorks does not supply such routines.
Phil.
thank u
"Phil Goddard" <philgodd...@telus.net> wrote in message <gpe2k9$la4$1...@fred.mathworks.com>...
At the MATLAB command line type
>> doc eml.extrinsic
or bring up the documentaton by typing
>> doc
and then in the search box at the top left search for the terms eml and extrinsic.
With the S-function it depends if you want to use the C-code as part of the simulation or just for (RTW) code generation.
If you want to use MATLAB's code during simulation and then your c-code during code generation then you could write an m-code S-Function to call the MATLA code and a TLC file which is used during code gen.
If you want to use the c-code during simulation then you'll want to write a c-code S-function, then if you also write a TLC file the code can be inlined, but if you don't wite a TLC file your code will be non-inlined.
Which is best is for you to determine given your real-time processor constraints.
You'll need to spend time reading much of the S-Function and RTW doc to decide which is best for you and how to go about implementing it.
Phill.
Thank u so much.Yes, i think am on the right track now reading more on s functions and RTW.
I read some where down the line in the documnetation provided that m-files (level 1 mfiles)are not suitable for real time implementation and we need to resort to C-Mex files.So now efforts are on to write a suitable C-Mex file for the same. Hope its in the right direction.
Thank u
"Phil Goddard" <philgodd...@telus.net> wrote in message <gpjhde$9or$1...@fred.mathworks.com>...
As suggetsed by you and keeping in mind my requirements, i have written a C-mex S function. Thank you.
Now I am faced with yet another difficulty. As I try to enter the name of my C-mex S function into the S function block (of simulink) and do simulation, an error appears that such a file does not exist. Shuould I do somethng more to link my Cmex S function with simulink so that it recognizes my S function? I tried to give the "mex file name" command at the command window...but again an error comes as ...
"C:\MATLAB701\BIN\WIN32\MEX.PL: Error: 'sdrecode.c' not found.
??? Error using ==> mex
Unable to complete successfully"
Hope to get a reply from you...
Thank you
Sangeetha
"Sangeetha Nair" <sangee...@gmail.com> wrote in message <gpkkkc$la3$1...@fred.mathworks.com>...
What is the exact command you typed?
Are you sure you have a file called sdrecode.c on your MATLAB path?
Phil.
Dear Phil
sdrecode is the name of my C mex s function(the flile I created).so to link it , I typed,
mex sdrecode.c, on which the above mentioned error came.
You have mentioned of a 'MATLAB path'.shud i be saving my new created file sdrecode into some such location. If so, wat could be this path?
(Only if I use mex to generate an executable, will my user generated C-Mex file(sdrecode) shall be recognised by Simulink, is it not? )
Thank You
Sangeetha
Yes, you need to mex the code (which generates the dll that is used by Simulink).
So you need to
>> mex sdrecode.c
The path is a fundamental aspect of MATLAB and you should look at the doc about it.
For your purposes assume MATLAB can only execute files that live in a directory that is on the MATLAB path.
To see the MATLAB path type
>> pathtool
which will bring up a UI showing a long list of directories.
sdrecode.c needs to be in one of these directores.
I would recommend that you have sdrecode.c in the same directory as your Simulink model.
If you can open your model then that directory is on the path and sdrecode.c should be mex-able.
If sdrecode.c is in the same directory as your Simulink model, and you can open your Simulink model, and you still get the above error when you try mexing then I can only assume that you have made a typo with respect to the file name.
Phil.
"Phil Goddard" <philgodd...@telus.net> wrote in message <gqun7h$efg$1...@fred.mathworks.com>...
Thank you for the instructions...there indeed was probelm with the path. The file was in the user profile directory and needed to be brought to the matlab path using the cd command....Now it is solved.
Thank you
Sangeetha
"Sangeetha Nair" <sangee...@gmail.com> wrote in message <gqv0uq$8rt$1...@fred.mathworks.com>...
Dear Phil
Thank you for your help so far which has brought me a lot forward in writng S-functions for my use, which i have been able to successfully compile and run in simulink. There is a slight problem when it comes to the real time implementation. I use math.h file in my s function. In MATLAB help, it is mentioned that "rtwintgt.h" file must be included after the math.h file , else ,though the S-function may run in simulink, it may not build in Real time workshop. However when I include the rtwintgt.h file, the mex operation is not done...the following error appears..
lcc preprocessor error: sdrecode.c:14 Could not find include file "rtwintgt.h"
Warning sdrecode.c: C:\MATLAB701\simulink\include\simulink.c: 2671 assignment of pointer to struct SimStruct_tag to pointer to double
Warning sdrecode.c: C:\MATLAB701\simulink\include\simulink.c: 2671 assignment of pointer to double to pointer to struct SimStruct_tag
1 errors, 2 warnings
C:\MATLAB701\BIN\WIN32\MEX.PL: Error: Compile of 'sdrecode.c' failed.
??? Error using ==> mex
Also, when I try to build the model which contains the S-function, without the rtwintgt.h file, the following error in generating TLC file appears
### Loading TLC function libraries
.....
### Initial pass through model to cache user defined code
Error: File: C:\Program Files\MATLAB\R2006a\toolbox\rtw\targets\rtwin\rtwin\rtwinlib.tlc Line: 28 Column: 16
Undefined identifier RTWinBoards
Error: File: C:\Program Files\MATLAB\R2006a\toolbox\rtw\targets\rtwin\rtwin\rtwinlib.tlc Line: 28 Column: 28
The left-hand side of a . operator must be a valid scope identifier
Error: File: C:\Program Files\MATLAB\R2006a\toolbox\rtw\targets\rtwin\rtwin\rtwinlib.tlc Line: 43 Column: 25
Undefined identifier RTWinBoards
Error: File: C:\Program Files\MATLAB\R2006a\toolbox\rtw\targets\rtwin\rtwin\rtwinlib.tlc Line: 43 Column: 39
The + operator only works on numeric arguments
Kindly help.
Thank u
This is the error which comes when grt.tlc is used as the system target file in the config parameters box. yet another error comes for , when the system target fiel used is rtwin.tlc
> Kindly help.
> Thank u