How can i convert my user class object into a mex file?
4 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
Walter Roberson
2021-10-28
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 个评论
Walter Roberson
2021-10-28
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.
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!