Non-constant expression or empty matrix. This expression must be constant because its value determines the size or class of some expression.
Ältere Kommentare anzeigen
How should I correctly pass in variable structure fields to support C/C++ code generation? My problem is simplified by the fact that the field name "str" of the following structure is dynamically changing and the exact value can only be determined at runtime
function out = testStruct()%#codegen
s = struct();
for i = 1:3
str = randGenChar();
s.(str) = i;
end
out = s;
end
function str = randGenChar()
basechar = 'abcdefghijklmnopqrstuvwxyz';
idx = randi(numel(basechar));
str = basechar(1:idx);
end
Then execute command line:
codegen -config:mex testStruct.m -report
Non-constant expression or empty matrix. This expression must be constant
because its value determines the size or class of some expression.
Error in ==> testStruct Line: 6 Column: 8
Code generation failed: To view the report, open('codegen/mex/testStruct/html/report.mldatx')
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu MATLAB Coder finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!