using python code in Matlab function block of Simulink
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
hi,
I defined a simple control algorithm in Python which returns 3 outputs. I want to call this function in a matlab function block and give its outputs to the outputs of this block in simulink. but the data that it receives from python are either a tuple or a list and after converting them to a cell, it is not possible to convert them in double, because in simulink it shows an error that cell2mat(), cellfun() or double() are not supported in its code generation.
considering that, i would be grateful if any of you can help me how i can convert python list or tuple to a double value in matlab function block.
0 comentarios
Respuestas (1)
arushi
el 22 de Ag. de 2024
Hi Leila Shams Ashkezari
To use ‘cell2mat()’ and other functions inside the ‘MATLAB function’ block, you can utilize the 'coder.extrinsic' function within the 'MATLAB function' block.
This function instructs the code generator to avoid generating the body of the extrinsic function. Instead, it enables the MATLAB engine to execute the function call.
Here's an example of using 'coder.extrinsic' with the 'cell2mat' function to convert a cell to the desired format:
coder.extrinsic('cell2mat');
cell2mat(variableName)
For more detailed information, you can consult the following documentation:
Hope this helps.
0 comentarios
Ver también
Categorías
Más información sobre Call Python from MATLAB en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!