MATLAB Answers

why I get error- undefined function or variable ‘templateMakefile’

3 views (last 30 days)
俊杰 王
俊杰 王 on 2 Nov 2020
Answered: Priysha LNU on 4 Jan 2021
I am trying to implement current execution with the thermal circuit system and circuit constructed in Simulink.
The thermal circuit system I built with Thermolib
I am getting the following error undefined function or variable ‘templateMakefile’
Kindly help me. Thanks in advance

Answers (1)

Priysha LNU
Priysha LNU on 4 Jan 2021
Hi,
Since I am unaware of the MATLAB release at your end, following are a few workarounds which have worked in different scenarios:
  1. Protecting a model might generate an error "Undefined function or variable 'templateMakefile'". This is a known issue in MATLAB R2013a and a detailed workaround has been provided in the following External Bug Report: https://www.mathworks.com/support/bugreports/911899?s_tid=srchtitle
  2. It is possible that specification of template makefile for generation of the makefile is missing altogether in the model configuration. Refer to the following documentation link for information on how to specify template makefile from which to generate the makefile: https://www.mathworks.com/help/rtw/ref/template-makefile.html?searchHighlight=templateMakefile&s_tid=srchtitle.
This error can also occur when MATLAB does not recognize the specified string as the name of a function on the MATLAB path or as a variable. "Undefined function or variable" can be caused by:
  1. A typographical error when typing a function or variable name (such as typing a 1 [one] when you intended to type an l [low-case L]). However, later versions of MATLAB try to resolve these typos with “Did you mean” suggestions.
  2. The wrong case for a function or variable name. Later versions of MATLAB try to resolve these typos with “Did you mean” suggestions.
  3. Changing directories so that a function you used is no longer on the MATLAB path.
  4. Trying to use a function for which you are not licensed or that belongs to a toolbox that isn’t installed. In later versions of MATLAB, this is not an “Undefined function or variable” error, and MATLAB lets you know that you are either not licensed to use the function or the appropriate toolbox is not installed.
  5. Calling an object method without an object as the first input.
  6. Using a MEX function that is compiled on a platform different from the one in use.
Solution:
Verify that the undefined function or variable is visible (it is on the path or in the current workspace) and that it has been defined before this line of code executes.
If you are certain the variable or function exists, verify the case of the function or variable name. If the undefined identifier is a function, the 'which' function can help you verify that it is visible to the function where the error occurs.
If you are having problems with your MATLAB search path, run the following MATLAB commands and then restart MATLAB.
restoredefaultpath % This will remove any custom paths
rehash toolboxcache
savepath
Hope this helps!
Thanks!
DISCLAIMER: These are my own views and in no way depict those of MathWorks.

Community Treasure Hunt

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

Start Hunting!

Translated by