1. Getting Started

This guide is intended for MATLAB users who want to exploit the features of the Python Anesthesia Simulator.
It explains how to set up your environment, instantiate a Patient object from MATLAB, and connect it to Simulink.


1.1. Prerequisites

  • MATLAB R2024b or later

  • Simulink toolbox

  • Python 3.12 (recommended: use a virtual environment)

  • The Python Anesthesia Simulator package installed (pip install . inside the cloned repository)


1.2. Configure the Python Environment

1.2.2. Activate the environment

Windows

your_environment\Scripts\activate

macOS / Linux

source your_environment/bin/activate

1.2.3. Install the simulator package

pip install .

1.3. Set Python Interpreter in MATLAB

Tell MATLAB to use your virtual environment’s Python interpreter:

% Windows example
pyenv('Version', 'C:\path\to\your_environment\Scripts\python.exe');

% macOS/Linux example
% pyenv('Version', '/Users/your_username/your_environment/bin/python');

1.4. Basic MATLAB Usage Example

% Import the simulator module
simulator = py.importlib.import_module('python_anesthesia_simulator.simulator');

% Define patient parameters
age = 18; height = 170; weight = 60; sex = 0; % 0=female, 1=male
sampling_time = 1;

% Create a Patient object
George = simulator.Patient([age, height, weight, sex], ts=sampling_time);

Once instantiated, you can call methods on the Python Patient object directly from MATLAB.