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 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Chitra Nayak
am 21 Jun. 2015
Kommentiert: Chitra Nayak
am 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 Kommentare
Akzeptierte Antwort
Walter Roberson
am 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 Kommentare
Walter Roberson
am 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.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Logical finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!