"Attempted to access an element that was not defined before use" - MATLAB Coder

10 次查看(过去 30 天)
I am trying to convert my A* algorithm code in MATLAB to C using the MATLAB Coder application. My MATLAB code however uses cell arrays and I have been trying to keep them while removing functions or variables like cell2mat that cannot be converted. I am left with one error that says a cell array is not defined. After checking through it, it has the actual indexes declared but nothing is defined in them. I cannot find the reason why it is doing it, and I do not know how to fix it.
astar_o.m is the original file which had a file that had to be converted into a matrix to find the map. astar.m is the file I am trying to convert into C and it takes in a matrix straightaway of the map.
If anyone can shed light, thanks.

回答(3 个)

Walter Roberson
Walter Roberson 2017-10-16
You did not declare Searchable to be varsize, so it is only 1 x 1, but you try to add multiple entries on the fly.

upol
upol 2018-4-6
how to define varsize?

upol
upol 2018-12-27
编辑:Walter Roberson 2018-12-27
I am trying to convert this simple code into excutable using matlab coder.
function y = hello_world
%#codegen
y = 'Hello World!';
converting to source code C works but when i change the build type to Executable
It gives me this error:
Build error: C compiler produced errors. See the Build Log for further details.
C:/PROGRA~3/MATLAB/SUPPOR~1/R2018b/3P778C~1.INS/MINGW_~1.INS/bin/../lib/gcc/x86_64-w64-mingw32/6.3.0/../../../../x86_64-w64-mingw32/lib/../lib\libmingw32.a(lib64_libmingw32_a-crt0_c.o):crt0_c.c:(.text.startup+0x2e): undefined reference to `WinMain'
collect2.exe: error: ld returned 1 exit status
gmake: *** [C:/dummy/hello_world.exe] Error 1
The make command returned an error of 2
'An_error_occurred_during_the_call_to_make' is not recognized as an internal or external command,
operable program or batch file.
Error(s) encountered while building "hello_world":
### Failed to generate all binary outputs.

类别

Help CenterFile Exchange 中查找有关 MATLAB Coder 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by