Show/Hide Toolbars

HOMER Pro 3.10

Navigation: Design > Components Tab > Controller > MATLAB Link

MatlabEndSimulation Function

Scroll Prev Top Next More


HOMER calls MatlabEndSimulation after all time steps have been simulated.

myErrs = MatlabEndSimulation(simulation_parameters, custom_variables)

The MatlabEndSimulation function generates errors and/or warnings, and returns them in the myErrs variable. The myErrs variable has two fields, simulation_errors and simulation_warnings. Both of these fields are cell arrays of strings. If you set warnings in simulation_warnings, they appear in the HOMER Optimization table on the Results page with a warning icon next to a simulation.


Click on the entry in the Optimization table to see the Simulation Results pop-up window. In the Simulation Results, the warning also appears as a larger yellow warning symbol at the bottom of the page. If you set any errors in the simulation_errors, the simulation is not feasible and does not appear in the results.

The following table contains examples of commands you might use in the MatlabEndSimulation function.



myErrs.simulation_warnings = {'This is a MATLAB test warning.'};

Adds an example warning to the myErrs variable.

if custom_variables.total_energy < 1e4

  myErrs.simulation_warnings =


    {'Not very much energy.'}];


You can use values set in custom_variables (in the MatlabDispatch function, for example) to trigger various warnings or errors.

myErr.severity_code = 'DISPATCH_CRITICAL_ERROR';

Setting this severity code skips the rest of the calculation.

See also


Cycle Charging