While using coder to convert matlab to c getting error - Subscripting into an empty matrix is not supported and dataToBoxNo 7 Undefined function or variable 'S1'. The first assignment to a local variable determines its class.
1 回表示 (過去 30 日間)
古いコメントを表示
Hello
I am using coder for first time. I am running into errors and I am not able to resolve. The code is the following.
function [S] = dataToBoxNo(megData, i, mn, mx, nPart, nDim, tau)
S = 0;
for j = 0:nDim-1
S1 = (fix((megData(i + j * tau) - mn)/((mx - mn) / nPart)))*nPart^j;
S = S + S1;
end
end
The error messages are
dataToBoxNo
6
Subscripting into an empty matrix is not supported.
2
dataToBoxNo
7
Undefined function or variable 'S1'. The first assignment to a local variable determines its class.
Can anyone please give hint as to what is to be done? I have couple other codes with same issue. This would shed light on how to resolve those. Thank you very much.
Chitra
0 件のコメント
採用された回答
Walter Roberson
2015 年 6 月 21 日
Use
S1 = 0;
before the loop so that the compiler knows the size and datatype of S1.
For the first bit, about indexing into an empty matrix: at least one of the calls made to this routine is passing in a matrix that is known to be empty.
5 件のコメント
Walter Roberson
2015 年 6 月 24 日
See http://www.mathworks.com/help/fixedpoint/ug/defining-variable-size-data-for-code-generation.html
Basically if you want to change the size of something you need to mark it specially.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!