- It depends on where this function needs to be called from. Can you elaborate on how the function needs to be used?
- For structure inputs/outputs, you need to use bus signals.
- I don't know that you see errors using 'int' - could you please paste the offending code and the error message.
- Again, please paste the offending code and the error message.
Using C code in s-functions
1 回表示 (過去 30 日間)
古いコメントを表示
Hi everyone;
I have a c code which need to be used in simulink block. The c code is working well, but I could not build a proper s-function with it. There are several errors;
1- In my c code there is a function other than main, How it should be implement in s function?
2- There is a struct which occurs a trouble also.
3- Does normal c syntax problem for matlab 'int' cause a error
4- Although I gave an initial value for my variables s function builder always wants a Ivalue error
If you help me I appreciate, I could not find a proper source yet. Thank you
0 件のコメント
回答 (3 件)
Kaustubha Govind
2013 年 3 月 5 日
2 件のコメント
Kaustubha Govind
2013 年 3 月 7 日
Ufuk: At this point, your code is not even in an S-function, but is a regular C-executable with a main(). You probably need to get help from a more C/C++ forum than a MATLAB/Simulink forum. It's hard for me to tell, because it's not clear where symbols like CLOCAL, and types like 'termios' are being defined. Please follow basic C rules and make sure that you can compile your code outside of MATLAB.
Dan
2013 年 7 月 9 日
You declare to include some header files
#include fcntl.h #include errno.h #include signal.h #include stdlib.h #include termios.h #include unistd.h #include stdio.h #include string.h
But the Matlab/Simlink coder may fail to find these files. Consequently, when your codes refer to the variables predefined in these header, the compiler reports errors. Please see the Simulink 7 Writing S-Functions reference, you may need to define LIB_PATH, etc to have Matlab/Simulink to know where there header files are
0 件のコメント
Ahmet Tuna
2017 年 5 月 26 日
Hey,
I have the same problem. I have C code, in this code i am communicating with serial port. The C code is working. I have made the changes for mexFunction. When i gave the command mex serialPort.c it also works and compiles. But when i use the function the serial does not open. Do you have a solution?
best regards
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Event Functions についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!