0

I'm having some trouble getting past the annoying limitation that MATLAB places on not using cell arrays for compiled C++ code.

Put most generally, I have a code that makes use of some MATLAB object, and I need to have multiple instances of that objects. This would be simple enough with cell arrays, but I can't figure out how to avoid using them.

A simple code that does this would be something like the following. I'm trying to get rid of using cell arrays both for the potential of code compilation, and possibly for more efficient memory allocation.

function surf_pts = foo(images)
surf_pts = cell(size(images,3),1);
for i = 1 : size(images,3)
   surf_pts{i} = detectSURFFeatures(images(:,:,i));
end

1 Answer 1

1

You can use an array of structures as follows:

function surf_pts = foo(images)

surf_pts = struct('Pts',[]);
surf_pts(1:size(images,3),1)=surf_pts;

for i = 1 : size(images,3)
   surf_pts(i).Pts= detectSURFFeatures(images(:,:,i));
end
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.