# External function in dynare 4.2

**URL:** <https://forum.dynare.org/t/external-function-in-dynare-4-2/2445>\
**Category:** Dynare help (legacy posts)\
**Created:** [4 April 2012 17:26 UTC](https://forum.dynare.org/t/external-function-in-dynare-4-2/2445 "2012-04-04T17:26:07Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![tanya](https://forum.dynare.org/letter_avatar_proxy/v4/letter/t/35a633/32.png) [@tanya](https://forum.dynare.org/u/tanya)\
**Post date:** [4 April 2012 17:26 UTC](https://forum.dynare.org/t/external-function-in-dynare-4-2/2445/1 "2012-04-04T17:26:07Z")

</div>

Dear All

I am estimating a linear model with highly nonlinear constraints on coefficients.  
These constraints can be written as function(coefficients)=function\_name(parameters) as an external (MATLAB) function.  
Because parameters are to be estimated I need to call it within the model(linear) block.

However, when I try to do so, by declaring external\_function(name=function\_name) and inserting line  
function(COEFFCIENTS)=function\_name(PARAMETERS)  
inside the model block, dynare tells me that I have more equations than variables and refuses to work.

What is the way around it?

Additionally, because dynare seems to be uncomfortable with many arguments of an external function, I pass them as globals, by including lines  
global PARAMETERS COEFFICIENTS;  
parameters PARAMETERS COEFFICIENTS;  
into both dynare file and into the corresponding MATLAB function. The function is then written as functionscalar\_out) = function\_name(scalar\_in)  
Dynare seems to forget globals half way. What is the way around it?

Many thanks

Tanya

---

_[View the full topic](https://forum.dynare.org/t/external-function-in-dynare-4-2/2445)._
