Notation - Steady State - Residuals

You should first read [Non-linear vs. exp() vs. log-linearized models).

1.) You can combine linear and nonlinear equations, but you need to make sure to define the corresponding relation between the log-level of the variable and the percentage deviation from trend. The nonlinear equations contain separate variables (e.g. y) that are not percentage deviations from steady state (e.g. yhat). To link them to the percentage deviations, you need to define them as separate variabes and link them to the linearized ones by

y_hat=log(y)-log(steady_state(y))

For y you then need to provide steady state values.

  1. The line
exp(yf)=exp(yhstar)+exp(bstar)-exp(bstar);

is not proper assignment in Matlab. It needs to be

yf=log(exp(yhstar)+exp(bstar)-exp(bstar));
  1. Statements like
exp(phstar+yhstar)

are usually not compatible with a proper substitution. Usually you have to substitute every variable individually, i.e.

exp(phstar)+exp(yhstar)

What you should to is solve the model without exp-notation first. Then either do the substitution after you computed the steady state of the levels correctly so that you know the log-levels or, even better, simply define the log-levels of the variables you need as additional variables:

log_y=log(y)

That would be less error-prone.