Simulink Real-Time 2016b: the build process fails for the example model slrttest with error "Subscript indices must either be real positive integers or logicals"

15 visualizzazioni (ultimi 30 giorni)
I'm using Matlab 2016b with Visual Studio 2017, when I tried to build the example model named slrttestmdl from the Simulink Real-Time getting started tutorials, I got the error mentioned in the question. I have already installed the patches from https://www.mathworks.com/matlabcentral/answers/335092-can-i-use-microsoft-visual-studio-2017-with-matlab and specified Visual Studio 2017 as the C++ compiler. Here's the information from the diagnostic viewer:
### Starting Simulink Real-Time build procedure for model: slrttestmdl
Code Generation 1
Elapsed: 7 sec
### Generating code into build folder: D:\Develope\Matlab\slrttestmdl_slrt_rtw
### Invoking Target Language Compiler on slrttestmdl.rtw
### Using System Target File: C:\Program Files\MATLAB\R2016b\toolbox\slrt\rtw\slrt.tlc
[ Warning: This model contains blocks that do not handle sample time
changes at runtime. To avoid incorrect results, only change
the sample time in the original model, then rebuild the model.]
### Loading TLC function libraries
### Initial pass through model to cache user defined code
### Caching model source code
### Generating TLC interface API.
### Writing source file slrttestmdl_capi.c
### Writing header file slrttestmdl_capi.h
### Writing header file slrttestmdl.h
### Writing header file slrttestmdl_types.h
### Writing header file rtwtypes.h
### Writing header file builtin_typeid_types.h
### Writing header file multiword_types.h
### Writing header file zero_crossing_types.h
### Writing source file slrttestmdl.c
### Writing header file slrttestmdl_private.h
### Writing header file rtmodel.h
### Writing source file slrttestmdl_data.c
### Writing header file rt_nonfinite.h
### Writing source file rt_nonfinite.c
### Writing header file rt_defines.h
### Writing header file rtGetInf.h
### Writing source file rtGetInf.c
### Writing header file rtGetNaN.h
### Writing source file rtGetNaN.c
### TLC code generation complete.
### Creating xPC Options Header file xpcoptions.h.
### Creating xPC Definition File xpcvcdll.def
### Creating model Hierarchy xml slrttestmdl.xml
### Creating model slrttestmdl_ref.m
### Create mapping files
### Patch xml-file
### Processing Template Makefile: C:\Program Files\MATLAB\R2016b\toolbox\slrt\rtw\slrt_vc.tmf
Error: Subscript indices must either be real positive integers or logicals.
Can anyone help me with this? Thanks
  6 Commenti
Jon Lobo
Jon Lobo il 24 Ott 2017
It seems that even though the 'model.mk' file can be found in the build directory, it can not be found by the compiler. It so happens that Microsoft changed Visual Studio 2017 to change the current directory to a default folder when any developer tools are run. When 'model.bat' calls 'vcvarsall.bat', it will change the current folder to the default directory which is not the 'model_grt_rtw' directory. Thus, 'nmake' will not be able to find 'model.mk' file. You can check that by try to generate the build any model for example a shipped model like xpcosc which can be accessed from the command line as below:
>>xpcosc
A workaround for this is to set an environment variable in MATLAB by executing the command below in the MALTAB command prompt:
>> setenv('VSCMD_START_DIR','%CD%')
You can add this to the "startup.m" file to ensure it is set at startup.
fuxin zhou
fuxin zhou il 26 Ott 2017
Hi jon,
I got the same problem. But the command is not working for my case. I still get same error. I have check with running a shaipped model like xpcosc. The same error pop up. Do you have alternative way to fix this error? Thanks

Accedi per commentare.

Risposte (2)

Moritz Boesenberg
Moritz Boesenberg il 2 Nov 2017
Hi,
I got the same error. I solved it by reinstalling the Compiler (Visual Studio 2015 Pro). Now it works.
cheers

fei ma
fei ma il 23 Lug 2019
I have the same problem, does any one solved the problem?

Community Treasure Hunt

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

Start Hunting!

Translated by