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 view (last 30 days)
Show older comments
Chitra Nayak
on 21 Jun 2015
Commented: Chitra Nayak
on 25 Jun 2015
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 Comments
Accepted Answer
Walter Roberson
on 21 Jun 2015
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 Comments
Walter Roberson
on 24 Jun 2015
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.
More Answers (0)
See Also
Categories
Find more on Logical 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!