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

1 回表示 (過去 30 日間)
Mads
Mads 2016 年 12 月 14 日
コメント済み: Mads 2016 年 12 月 15 日
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 ":"

回答 (1 件)

James Tursa
James Tursa 2016 年 12 月 14 日
What happens if you use explicit indexes?
V(1:n,1) = (1/beta)*w;
  2 件のコメント
Mads
Mads 2016 年 12 月 15 日
Apparently, it is not the issue after all. I did a test earlier in the code:
test= rand(5,1);
test2 = zeros(5,2);
test2(:,1) = test;
test2(1:5,2) = 2*test;
and it passes, so basically, the original error is misleading. So there is a main function and a subfunction. And things start to go wrong from the point where I call the subfunction in which the original error was, although, I conduct the same test in the subfunction and it passes. So I'm left without a clue. I worry there is one error leading to other errors...
Mads
Mads 2016 年 12 月 15 日
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...

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeMATLAB Coder についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by