How can i convert my user class object into a mex file?
4 views (last 30 days)
Show older comments
I have read https://www.mathworks.com/help/matlab/matlab_external/mex-functions-for-class-methods-1.html that I can convert functions into mex file and call these functions in the object's methods.
But ones I try to convert the functions using the coder app, I receive the following error: Entry point cannot be inside a class folder.
What I am doing wrong?
My function, defined in the method class is a sort of:
function out = step(Obj)
modulated_sym = zeros(1,Obj.FEC*Obj.signal_config.n_sym);
for nn = 1:Obj.FEC
%%%%%%%%%%%%%%%%%%%%%%%%%%%% Turbo Encoder %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
[coded_bits_to_punc] = step(Obj.signal_config.hTEnc,Obj.tx_bits((length(Obj.tx_bits)/Obj.FEC)*(nn-1)+1:nn*(length(Obj.tx_bits)/Obj.FEC)).');
coded_bits_to_punc = coded_bits_to_punc(1:end-16);
coded_bits_to_punc = [coded_bits_to_punc(1:3:end-2); coded_bits_to_punc(2:3:end-1); coded_bits_to_punc(3:3:end)];
Obj.len_to_punc = length(coded_bits_to_punc);
coded_bits = coded_bits_to_punc(Obj.signal_config.punc_pattern);
.....
end
Is the " Obj." that is not working for the coder?
0 Comments
Answers (1)
Walter Roberson
on 28 Oct 2021
You cannot use MATLAB Coder to convert a class method into a mex file. You can only convert functions outside of classes.
This implies that the function to convert could only use the public interfaces to the object properties to get data or change the object.
2 Comments
Walter Roberson
on 28 Oct 2021
struct() are faster than objects. Carefully arranged numeric arrays are faster than struct() .
If you use a class folder, then the class folder can contain mex files. However, you cannot selectively convert class methods written in m-code into mex; furthermore, the mex API makes objects pretty much opaque, if I recall correctly.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!