How can I generate c++ code of a matlab function using embedded coder from simulink?

2 visualizaciones (últimos 30 días)
Hi,
I would like to use embedded coder for this function from the 5G toolbox:
function harqProcesses = hNewHARQProcesses(numHARQProcesses,rvsequence,ncw)
harqProcess.RVSequence = rvsequence; % Sharing one rvsequence per CW
harqProcess.ncw = ncw; % Set number of codewords
harqProcess.blkerr = zeros(1,ncw); % Initialize block errors
harqProcess.RVIdx = ones(1,ncw); % Add RVIdx to process
harqProcess.RV = rvsequence(ones(1,ncw));
% Create HARQ processes as indicated by numHARQProcesses
harqProcesses = repmat(harqProcess,numHARQProcesses,1);
end

Respuestas (2)

AnnQ
AnnQ el 18 de Jun. de 2021
Hello,
You can try adding a MATLAB Function block in your model which supports C/C++ code generation from Embedded Coder: https://www.mathworks.com/help/simulink/ug/what-is-a-matlab-function-block.html?searchHighlight=matlab%20function%20block&s_tid=srchtitle
Here is a simple example you can try to get started: https://www.mathworks.com/help/simulink/ug/creating-an-example-model-that-uses-a-matlab-function-block.html

Janani Janagarajan Kalaivani
Janani Janagarajan Kalaivani el 18 de Jun. de 2021
Hi,
There are two possible workflows.
  • Directly generate C++ code from the Matlab script using Matlab
  • Use Matlab Function Block in Simulink and then generate C++ code using Simulink Coder
Since you have Embedded Coder, you have access to both Matlab Coder & Simulink Coder. Hence to assist you further, let me know your intended workflow.
Examples for Matlab Coder
Examples for Simulink Coder
https://www.mathworks.com/help/simulink/slref/matlabfunction.html
Also, the below link gives you the list of functions compatible for Code Generation.

Categorías

Más información sobre Deployment, Integration, and Supported Hardware 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!

Translated by