In this tutorial, we are going to learn how we can convert the Matlab function into the c or c++ code. Note that the existing Matlab function needs to have c/c++ code generation extended capabilities.
Let's look into the sample Matlab scripts.
codegen.m
function y = codegen(I1)
%#codegen
y = typecast(I1, 'double');
Here, we are going to generate c code for function typecast of Matlab as given here. You can see the function does have the c/c++ code generation capabilities.The first thing to do is add %#codegen as shown above. Open the file script on the editor and go to the APPS tab on the Matlab editor and you can find the MATLAB Coder option. Click on it.
Once click on the next button you can see the screen to check the issue, so you either check the issue or remove it by clicking on the screen outside of it. And click next to generate the code.
Click on generate button to generate the code. After build success, you can see the generated code as below:
0 comments:
New comments are not allowed.