im using 'accumarray' function in my prgm.I need to convert my prgm to C code using CODER but 'accumarray' does not support this conversion.Is tre any means to convert it or any otr options?????pls leme know
1 回表示 (過去 30 日間)
古いコメントを表示
karthik
2014 年 7 月 7 日
回答済み: Abhiram Bhanuprakash
2014 年 10 月 28 日
im using 'accumarray' function in my prgm.I need to convert my prgm to C code using CODER codegeneration but 'accumarray' does not support this conversion.Is tre any means to convert it into C or any otr options?????pls leme know
0 件のコメント
採用された回答
Abhiram Bhanuprakash
2014 年 10 月 28 日
Hi Karthik,
You are right. The function 'accumarray' is not supported by MATLAB Coder, as you can see in the list here
To work around this issue, I have used functions which are supported by MATLAB Coder, and I have written a MATLAB script 'accarr.m', which seems to work (attached). I have written it in a way that it will only work for 1 D and 2 D arrays for 'subs'. I have tested it and it seems to give the same result as the MATLAB function 'accumarray'.
Following is an explanation of why I used some lines in the code:
1. siz = max(subs) is because the maximum value of 'subs' determines the size of the result. For example, if
subs =
1 1
2 2
4 1
2 1
4 2
Then the result should have 4 rows and 2 columns, right? max(subs) returns precisely 4 and 2, because the max function operates column-wise (as is the case with most functions in MATLAB).
2. 'numel' gives you the number of elements in an array/matrix. I am using numel(siz) to check if the result we want is 1 D or 2 D, in other words if 'subs' is 1 D or 2 D. Since siz = max(subs), if 'subs' is 1 D, siz will also be 1 D, and if subs is 2 D, siz will also be 2 D. You can also use size(subs,2) instead of numel(siz), if it is confusing to you. For information on 'size' function, check this out
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Loops and Conditional Statements についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!