MATLAB Function block limitations

조회 수: 4 (최근 30일)
maiaL
maiaL 2019년 11월 4일
댓글: Saeed Ahmadzadeh Mahboobi 2020년 11월 19일
I'm trying to implement MATLAB code into a MATLAB function block in Simulink which would need to do the following: parse data/text from a .INI file, extract data points, interpolate the input x of the MATLAB function block based on such data points and output y.
This block should be able to be compiled by the PLC Coder.
I wrote a MATLAB script that could do what I wanted, but as I tried to implement it in a MATLAB function block, I ran into all sorts of problems, from variable-size data, to functions not supported for code generation (already read a lot of documentation regarding these).
I'm wondering if this is the right approach to implement such functionality to a Simulink Model. I was expecting that whichever .m script I wrote to perform such functionality would work seamlessly in the MATLAB Function block. It doesn't seem to be the case. Is this the correct approach or will I perhaps have an easier time implementing this natively in Simulink with block logic, instead of the Function block, for example?
  댓글 수: 1
Saeed Ahmadzadeh Mahboobi
Saeed Ahmadzadeh Mahboobi 2020년 11월 19일
I have also faced this Problem.
I wanted to even change the data type of the MATLAB-function from double to boolean (logical). So i wrote in the MATLAB-function " x = logical(k) ". but I get the error that changing the data types are not possible. but when i use the block " Convert " from the simulink library, it works !!
Apparently, MATLAB-Function has restrictions that won't let you work with them just like an m-file.

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

답변 (1개)

Jyotsna Talluri
Jyotsna Talluri 2019년 11월 7일
We can implement MATLAB code in simulink by S-Functions as the MATLAB Function block is not supported in all cases
Refer to the below link
  댓글 수: 1
maiaL
maiaL 2019년 11월 7일
S-Functions are not supported by the PLC Coder, that's why I'm writing code to be read by a MATLAB Function block. Previously, a S-Function was already being used. However, I've found some workarounds to the problems I was having.
Most issues were coming from a section of the code that was parsing a text file. Dealing with variable-size chars was tricky. I bypassed that parsing step (might not need it, in the end) and things are going somewhat smoothly.

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

카테고리

Help CenterFile Exchange에서 Event Functions에 대해 자세히 알아보기

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by