How can I generate c++ code of a matlab function using embedded coder from simulink?
2 views (last 30 days)
Show older comments
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
0 Comments
Answers (2)
AnnQ
on 18 Jun 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
0 Comments
Janani Janagarajan Kalaivani
on 18 Jun 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.
0 Comments
See Also
Categories
Find more on Simulink Coder in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!