Subscripting into an mxArray is not supported for code generation - I think it's the colon that's the issue

3 views (last 30 days)
This part of my code
V = zeros(n,m+1);
V(:,1) = (1/beta)*w;
is giving me an error "Subscripting into an mxArray is not supported for code generation", when I use MATLAB Coder to create a Mex file. But if I can't fill V that way and so forth what is the correct way to do it? Other places I get "Unexpected MATLAB operator" and the MATLAB Coder points me to the ":"

Answers (1)

James Tursa
James Tursa on 14 Dec 2016
What happens if you use explicit indexes?
V(1:n,1) = (1/beta)*w;
  2 Comments
Mads
Mads on 15 Dec 2016
I finally managed to locate the seeding error of all other errors. I'm disappointed by the fact that I was not allowed to use spdiags() even though I made it extrinsic ("coder.extrinsic('spdiags')"). This has resulted in a workaround that finally has made the MEX slower than the native matlab script because I at some point am forced to use non-sparse matrices...

Sign in to comment.

Categories

Find more on MATLAB Code Analysis in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!