Design a DC-DC Boost Converter in MATLAB

Simulate an EV battery boost converter with closed-loop PI control in Simulink.

Introduction

30 Second Summary

Every electric vehicle needs to convert its battery voltage to the higher voltage required by the drivetrain. This voltage conversion happens through a power electronics circuit called a DC-DC boost converter.

In this project, you will design and simulate a DC-DC boost converter in MATLAB/Simulink that steps up a 200V EV battery to the 400V DC bus needed by a traction inverter. You will build a closed-loop PI controller, test it under realistic load transients, and generate portfolio-ready plots.

What You'll Build

A complete EV battery-to-DC-bus boost converter simulation with closed-loop PI voltage control and transient performance validation using Simscape Electrical.

By the end of this project, you'll have:

  • A Simulink model of a DC-DC boost converter power stage using the prebuilt Boost Converter block with MOSFET switching, along with a MATLAB parameter script defining all converter specifications.
  • A PI voltage controller that regulates output voltage under load disturbances, with verified gain margin and phase margin from a Bode plot.
  • Portfolio-ready simulation results including output voltage regulation waveforms, inductor current plots, and transient response to a load step simulating EV acceleration.
  • Secret Mission: Add input voltage variation simulating a battery SOC drop and verify the controller maintains output regulation.

Are there any prerequisites?

You need a university MATLAB license with Simulink and the Simscape Electrical toolbox installed. You should also have a basic understanding of circuit elements like inductors, capacitors, MOSFETs, and diodes.

Set Up MATLAB and Create the Parameter Script

Before you can simulate anything, your converter needs a complete set of specifications. These parameters define the physical components (inductor, capacitor), the operating conditions (input voltage, output voltage, switching frequency), and the control strategy (PI gains, crossover frequency).

In this step, you will create a MATLAB script that calculates and stores every parameter the simulation needs. You will also create a blank Simulink model that you will build on in the next step.

In this step, get ready to:
  • Create a parameter script with all converter specifications.
  • Create a blank Simulink model for the boost converter.
  • Run the parameter script to load values into the MATLAB workspace.
Create the parameter script

Your EV_Boost_Converter folder is already set as the Current Folder in MATLAB. The first file you need is a script that defines every numerical value the simulation will reference.

  • Create a new script by clicking New Script on the Home tab of the MATLAB toolstrip.
  • Save the file immediately as boost_params.m in your EV_Boost_Converter folder (Ctrl+S on Windows, Cmd+S on macOS).

Now you will fill in the converter specifications. The first section defines the power stage: input voltage from the EV battery, output voltage for the DC bus, power rating, and switching frequency. The derived parameters are calculated directly from these values.

  • Enter the following code into boost_params.m:
%% EV Boost Converter Parameters
% DC-DC Boost Converter: Battery (200V) to DC Bus (400V)
% Application: EV traction inverter DC bus supply

%% Power Stage Specifications
Vin = 200;          % Input voltage [V] - EV battery pack nominal
Vout = 400;         % Output voltage [V] - DC bus for traction inverter
Pout = 2000;        % Output power [W] - nominal load
fsw = 20e3;         % Switching frequency [Hz]
Tsw = 1/fsw;        % Switching period [s]

%% Derived Parameters
R_load = Vout^2 / Pout;    % Load resistance [ohm] = 80 ohm
D_nominal = 1 - Vin/Vout;  % Nominal duty cycle = 0.5
Iin = Pout / Vin;          % Average input (inductor) current [A] = 10A

%% Passive Component Sizing
% Inductor: sized for CCM with 30% current ripple
delta_IL = 0.3 * Iin;                      % Inductor current ripple [A]
L = (Vin * D_nominal) / (fsw * delta_IL);  % Inductance [H]

% Output Capacitor: sized for 1% voltage ripple
delta_Vout = 0.01 * Vout;                          % Output voltage ripple [V]
C = (Pout * D_nominal) / (Vout * delta_Vout * fsw); % Capacitance [F]

What does this code do?

The Power Stage Specifications section sets the operating point: a 200V battery pack feeding a 400V DC bus at 2kW, switching at 20 kHz. These numbers represent a realistic EV traction inverter supply.

The Derived Parameters section computes values that follow directly from the specs. D_nominal = 1 - Vin/Vout = 0.5 is the boost converter voltage gain formula rearranged for duty cycle.

The Passive Component Sizing section calculates the inductor value needed to stay in continuous conduction mode (CCM) with 30% ripple, and the capacitor needed to keep output voltage ripple below 1%.

  • You will not see a change yet. The next code block completes the file.

The second half of the script defines the PI controller parameters and a display summary that prints all values to the Command Window when you run the script.

  • Add the following code directly below what you just typed in boost_params.m:
%% PI Controller Design
% Small-signal transfer function: Gvd(s) = Vout*(1 - s*L/(R_load*(1-D_nominal)^2))
%                                           / (1 + s*L/(R_load*(1-D_nominal)^2) + s^2*L*C/(1-D_nominal)^2)
% Right-half-plane zero frequency:
f_rhpz = (R_load * (1-D_nominal)^2) / (2*pi*L);  % RHP zero [Hz]

% Design targets
fc = 700;                    % Crossover frequency [Hz] (well below f_rhpz)
wc = 2*pi*fc;               % Crossover frequency [rad/s]
phase_margin_target = 55;    % Target phase margin [degrees]

% Plant DC gain (duty-to-output at DC)
Gvd_dc = Vout / (1-D_nominal);  % = 800 V

% PI gains (conservative initial values for stable operation)
Kp = 0.001;    % Proportional gain
Ki = 0.5;      % Integral gain

%% Simulation Parameters
Vref = Vout;        % Reference voltage [V]
t_sim = 0.1;        % Simulation stop time [s]

%% Display Summary
fprintf('=== EV Boost Converter Design Summary ===\n');
fprintf('Input: %d V (battery)\n', Vin);
fprintf('Output: %d V (DC bus)\n', Vout);
fprintf('Power: %d W\n', Pout);
fprintf('Duty Cycle: %.2f\n', D_nominal);
fprintf('Inductance: %.2f mH\n', L*1e3);
fprintf('Capacitance: %.2f uF\n', C*1e6);
fprintf('Load Resistance: %.1f ohm\n', R_load);
fprintf('Switching Frequency: %d kHz\n', fsw/1e3);
fprintf('RHP Zero: %.0f Hz\n', f_rhpz);
fprintf('PI Gains: Kp = %.4f, Ki = %.2f\n', Kp, Ki);
fprintf('==========================================\n');

What does this code do?

The PI Controller Design section sets the control loop targets. The right-half-plane (RHP) zero is a characteristic of boost converters that limits how fast the controller can respond. The crossover frequency of 700 Hz is chosen well below the RHP zero so the loop stays stable.

The PI gains (Kp = 0.001, Ki = 0.5) are conservative starting values. They will keep the system stable while you verify the model in later steps.

The Display Summary section prints a formatted table of all design values to the Command Window. This gives you instant visual confirmation that all parameters loaded correctly.

  • Save boost_params.m by pressing Ctrl+S (Windows) or Cmd+S (macOS).
  • Run the script by clicking the Run button in the Editor tab, or by typing boost_params in the Command Window and pressing Enter.
  • You should see the Design Summary table printed in the Command Window, starting with === EV Boost Converter Design Summary ===.

Not seeing the summary output?

Make sure you saved the file before running it. MATLAB runs the saved version, not what is currently in the editor.

Check that your Current Folder is still set to EV_Boost_Converter. If MATLAB cannot find the script, it will show an error in red text.

help me debug why boost_params.m won't run in MATLAB

✔️ Awesome, I've got everything!

Great. Double check you have saved boost_params.m and that all the workspace variables appear in the Workspace panel on the right side of MATLAB.

ⓧ I'd like to double check the full code

%% EV Boost Converter Parameters
% DC-DC Boost Converter: Battery (200V) to DC Bus (400V)
% Application: EV traction inverter DC bus supply

%% Power Stage Specifications
Vin = 200;          % Input voltage [V] - EV battery pack nominal
Vout = 400;         % Output voltage [V] - DC bus for traction inverter
Pout = 2000;        % Output power [W] - nominal load
fsw = 20e3;         % Switching frequency [Hz]
Tsw = 1/fsw;        % Switching period [s]

%% Derived Parameters
R_load = Vout^2 / Pout;    % Load resistance [ohm] = 80 ohm
D_nominal = 1 - Vin/Vout;  % Nominal duty cycle = 0.5
Iin = Pout / Vin;          % Average input (inductor) current [A] = 10A

%% Passive Component Sizing
% Inductor: sized for CCM with 30% current ripple
delta_IL = 0.3 * Iin;                      % Inductor current ripple [A]
L = (Vin * D_nominal) / (fsw * delta_IL);  % Inductance [H]

% Output Capacitor: sized for 1% voltage ripple
delta_Vout = 0.01 * Vout;                          % Output voltage ripple [V]
C = (Pout * D_nominal) / (Vout * delta_Vout * fsw); % Capacitance [F]

%% PI Controller Design
% Small-signal transfer function: Gvd(s) = Vout*(1 - s*L/(R_load*(1-D_nominal)^2))
%                                           / (1 + s*L/(R_load*(1-D_nominal)^2) + s^2*L*C/(1-D_nominal)^2)
% Right-half-plane zero frequency:
f_rhpz = (R_load * (1-D_nominal)^2) / (2*pi*L);  % RHP zero [Hz]

% Design targets
fc = 700;                    % Crossover frequency [Hz] (well below f_rhpz)
wc = 2*pi*fc;               % Crossover frequency [rad/s]
phase_margin_target = 55;    % Target phase margin [degrees]

% Plant DC gain (duty-to-output at DC)
Gvd_dc = Vout / (1-D_nominal);  % = 800 V

% PI gains (conservative initial values for stable operation)
Kp = 0.001;    % Proportional gain
Ki = 0.5;      % Integral gain

%% Simulation Parameters
Vref = Vout;        % Reference voltage [V]
t_sim = 0.1;        % Simulation stop time [s]

%% Display Summary
fprintf('=== EV Boost Converter Design Summary ===\n');
fprintf('Input: %d V (battery)\n', Vin);
fprintf('Output: %d V (DC bus)\n', Vout);
fprintf('Power: %d W\n', Pout);
fprintf('Duty Cycle: %.2f\n', D_nominal);
fprintf('Inductance: %.2f mH\n', L*1e3);
fprintf('Capacitance: %.2f uF\n', C*1e6);
fprintf('Load Resistance: %.1f ohm\n', R_load);
fprintf('Switching Frequency: %d kHz\n', fsw/1e3);
fprintf('RHP Zero: %.0f Hz\n', f_rhpz);
fprintf('PI Gains: Kp = %.4f, Ki = %.2f\n', Kp, Ki);
fprintf('==========================================\n');

Why PI instead of PID?

Boost converters have a right-half-plane zero in their control-to-output transfer function. This limits how fast you can push the controller bandwidth. A PI controller is standard practice for voltage-mode boost converters because derivative action amplifies switching noise without adding meaningful stability benefit at these constrained bandwidths.

Create the Simulink model

With all parameters loaded into the workspace, you need a Simulink model file where you will build the converter circuit in the next step.

  • Open the Simulink Start Page by typing this command in the Command Window:
simulink
  • On the Simulink Start Page, click Blank Model.
  • Save the model immediately by pressing Ctrl+S (Windows) or Cmd+S (macOS).
  • In the Save dialog, navigate to your EV_Boost_Converter folder and save as ev_boost_converter.slx.

Why save an empty model now?

Saving immediately ensures the .slx file lives in the same folder as your parameter script. When you run boost_params.m before simulating, MATLAB can find both files because they share the same Current Folder.

  • Confirm both files exist in your folder by typing this in the Command Window:
dir('*.m'), dir('*.slx')
  • You should see boost_params.m and ev_boost_converter.slx listed in the output.

Only seeing one file?

If ev_boost_converter.slx is missing, you may have saved it to a different folder. Check the title bar of the Simulink window. It should show the full path ending in EV_Boost_Converter/ev_boost_converter. If not, use File > Save As to save it in the correct location.

help me find where my Simulink model saved so I can move it to the right folder

Your design parameters are locked in and your model is ready to receive components. Next up, you will place the Boost Converter block, wire the power stage, and watch your first switching waveform appear.

Build the Boost Converter Power Stage

Your parameter script is loaded and your blank Simulink model is ready. Now you need to build the actual circuit that steps up 200V from the EV battery to 400V for the DC bus.

A boost converter achieves this voltage step-up using an inductor, a switching device (MOSFET), a diode, and an output capacitor. In this step, you will place and wire all the power stage components in Simulink, then run your first simulation to confirm the converter produces 400V output.

In this step, get ready to:
  • Place and configure the Boost Converter block with MOSFET switching.
  • Wire the DC source, load resistor, and voltage measurement.
  • Add an open-loop PWM gate signal and run your first simulation.
Place the Boost Converter block

Simscape Electrical provides a prebuilt Boost Converter block that internally contains the correct topology (inductor, MOSFET, diode, output capacitor). Using this block eliminates wiring errors while still exposing all the parameters you need to configure.

  • Switch to your ev_boost_converter.slx model in Simulink.
  • Open the Library Browser by clicking Library Browser on the Simulation tab in the Simulink Toolstrip.
  • In the Library Browser tree, navigate to: Simscape > Electrical > Semiconductors and Converters > Converters.
  • Drag the Boost Converter block into your model canvas.
  • Double-click the Boost Converter block to open its parameters dialog.
  • Set Modeling option to Nonsynchronous converter.
  • Set Switching device to MOSFET.
  • Set Gate-control port to PS.
  • Set Inductance to L (your workspace variable from the parameter script).
  • Set Capacitance to C (your workspace variable).
  • Click OK to close the dialog.

What is the Boost Converter block?

The prebuilt Boost Converter block from Simscape Electrical internally contains a nonsynchronous boost topology: an inductor, a switching device, a diode, and an output capacitor. By setting the switching device to MOSFET and entering your workspace variables for L and C, you get a fully parameterized power stage without manually wiring individual components.

The PS gate-control port accepts a physical signal (a value between 0 and 1) representing the duty cycle. This is how you will control the converter's output voltage.

You should see the Boost Converter block on your canvas showing the correct topology icon with inductor, switch, diode, and capacitor symbols.

Don't see the Converters library?

Make sure you have Simscape Electrical installed. Return to MATLAB and type ver in the Command Window to confirm it appears in the list. If missing, install it via the Add-On Explorer.

Help me find the Boost Converter block

Add the DC source, load, and measurement

The Boost Converter block handles the switching topology, but you still need to provide an input voltage source (representing the EV battery), a load resistor (representing the traction inverter's power draw), and a voltage sensor to measure the output.

  • From the Library Browser, navigate to Simscape > Electrical > Sources. Drag a DC Voltage Source block into your model.
  • Double-click the DC Voltage Source and set Constant voltage to Vin.
  • Navigate to Simscape > Electrical > Passive. Drag a Resistor block into your model.
  • Double-click the Resistor and set Resistance to R_load.
  • Navigate to Simscape > Electrical > Sensors. Drag a Voltage Sensor block into your model.
  • Navigate to Simscape > Utilities. Drag a PS-Simulink Converter block into your model.
  • From Simscape > Utilities, also drag a Solver Configuration block into your model.
  • Navigate to Simscape > Electrical > Connectors. Drag an Electrical Reference (ground) block into your model.

Now wire the circuit together:

  • Connect the DC Voltage Source positive (+) terminal to the Boost Converter input (+).
  • Connect the Boost Converter output (+) to the top terminal of the Resistor.
  • Connect the Resistor bottom terminal to the DC Voltage Source negative terminal (route through the Electrical Reference block for ground).
  • Place the Voltage Sensor in parallel across the Resistor (positive lead to Resistor top, negative lead to ground).
  • Connect the Voltage Sensor output (physical signal) to the PS-Simulink Converter input.
  • Connect the Solver Configuration block to any electrical node in your circuit.

Why do I need a Solver Configuration block?

Every Simscape physical network requires a Solver Configuration block. It tells Simulink how to handle the physical equations in your circuit. Without it, the model cannot simulate.

The Electrical Reference block provides the ground node. All Simscape Electrical circuits need a reference potential, just like a real circuit needs a ground return path.

Check your model canvas. All connection lines should be solid black with no red error indicators.

Seeing red lines on connections?

Red connection lines mean a port type mismatch. Make sure you are connecting physical ports (Simscape) to physical ports, not to Simulink signal ports. The PS-Simulink Converter is the bridge between the two domains.

Help me diagnose my connection errors

Add the PWM gate signal and run the simulation

The Boost Converter block needs a duty cycle signal at its gate port to switch the MOSFET. For now, you will use a fixed duty cycle of 0.5 (open-loop) to verify the power stage produces approximately 400V output.

  • From the Library Browser, navigate to Simulink > Sources. Drag a Constant block into your model.
  • Double-click the Constant block and set its value to D_nominal.
  • From Simscape > Utilities, drag a Simulink-PS Converter block into your model.
  • Wire the Constant block output to the Simulink-PS Converter input.
  • Wire the Simulink-PS Converter output to the Boost Converter G (gate) port.
  • From Simulink > Sinks, drag a Scope block into your model.
  • Connect the PS-Simulink Converter output (your Vout measurement) to the Scope input.

Why use a Simulink-PS Converter here?

The Constant block produces a Simulink signal, but the Boost Converter's G port expects a physical signal (PS). The Simulink-PS Converter bridges these two domains.

Similarly, the PS-Simulink Converter you placed earlier converts the Voltage Sensor's physical output into a Simulink signal that the Scope can display.

Now configure the solver and run the simulation:

  • Open the Configuration Parameters dialog by pressing Ctrl+E.
  • In the Solver pane, set Type to Variable-step.
  • Set Solver to ode23t (mod. stiff/Trapezoidal).
  • Set Stop time to 0.1.
  • Click OK to close the dialog.
  • Click the green Run button in the Simulink Toolstrip (or press Ctrl+T) to start the simulation.
  • Double-click the Scope block to view the output voltage waveform.

Why ode23t for power electronics?

The ode23t solver uses the trapezoidal rule, which handles the moderately stiff equations in switching circuits without adding numerical damping. MathWorks recommends it for Simscape Electrical models because it efficiently handles the stiff DAEs produced by switching power converters.

Your Scope should show the output voltage settling near 400V with visible switching ripple. This confirms the boost converter gain formula: Vout/Vin = 1/(1-D) = 1/(1-0.5) = 2.

  • Save your model by pressing Ctrl+S.

Simulation fails or voltage not near 400V?

Make sure you ran boost_params.m before simulating. The workspace must contain L, C, Vin, R_load, and D_nominal. Switch to the MATLAB Command Window and type whos to confirm these variables are loaded.

If you see an algebraic loop error, check that the Solver Configuration block is connected to an electrical node in your circuit. Every Simscape network needs exactly one Solver Configuration block.

Help me troubleshoot my boost converter simulation

Your power stage is working. The converter steps up 200V to approximately 400V using a fixed duty cycle of 0.5.

Next up, you will close the feedback loop with a PI controller so the output voltage stays at exactly 400V even when the load changes.

Design and Implement the PI Controller

Your open-loop boost converter produces 400V, but it has no way to respond to changes in load.

In a real EV, the traction inverter draws more current during acceleration and less during cruising. Without feedback, the output voltage would sag or spike with every load change. In this step, you will close the loop with a PI controller that continuously adjusts the duty cycle to hold the DC bus at exactly 400V.

In this step, get ready to:
  • Build a closed-loop feedback path with a PI controller and saturation limits.
  • Verify the controller regulates output voltage within 20ms of startup.
  • Test the system against a 2x load step simulating an EV acceleration event.
Replace the open-loop constant with a PI feedback loop

The Constant block currently feeds a fixed duty cycle of 0.5 into the gate port. You will replace it with a feedback loop that compares the measured output voltage to the 400V reference and adjusts the duty cycle automatically.

  • In your Simulink model ev_boost_converter.slx, select the Constant block (the one outputting D_nominal) and delete it.
  • Open the Simulink Library Browser (View > Library Browser).
  • Navigate to Simulink > Continuous and drag a PID Controller block into your model.
  • Double-click the PID Controller block.
  • Set Controller type to PI.
  • Set Proportional (P) to Kp (workspace variable).
  • Set Integral (I) to Ki (workspace variable).
  • Click OK to close the dialog.
  • Navigate to Simulink > Sources and drag a Constant block into your model for the voltage reference.
  • Double-click it and set the value to Vref (which equals 400 in your workspace).
  • Navigate to Simulink > Math Operations and drag a Sum block into your model.
  • Double-click the Sum block and set the List of signs to + - (this computes the error: reference minus measured).
  • Navigate to Simulink > Discontinuities and drag a Saturation block into your model.
  • Double-click the Saturation block.
  • Set Upper limit to 0.9.
  • Set Lower limit to 0.1.

Why add saturation limits?

A duty cycle below 0.1 or above 0.9 can damage real MOSFET switches or cause the converter to operate in an unstable region.

The Saturation block clamps the PI output to a safe operating range, preventing the controller from ever requesting an extreme duty cycle.

  • Wire the feedback loop in this order:
  • Connect the Vref Constant output to the + input of the Sum block.
  • Connect the PS-Simulink Converter output (your measured Vout) to the - input of the Sum block.
  • Connect the Sum block output (error signal) to the PID Controller input.
  • Connect the PID Controller output to the Saturation block input.
  • Connect the Saturation block output to the existing Simulink-PS Converter, which feeds the Boost Converter G port.

What does this feedback loop do?

The Sum block computes the error between the 400V reference and the actual measured output voltage.

The PI controller processes this error: the proportional term responds to the current error magnitude, while the integral term accumulates past errors to eliminate steady-state offset. The result is a duty cycle command that the Saturation block clamps to [0.1, 0.9] before passing it to the power stage.

Check that no red error indicators or algebraic loop warnings appear on your connection lines.

Seeing an algebraic loop warning?

Algebraic loops occur when a signal feeds back to itself without any delay. Make sure the PS-Simulink Converter and Simulink-PS Converter blocks are both present in the feedback path. These converter blocks introduce the necessary signal conditioning to break the loop.

Also confirm the PID Controller is set to Continuous time (the default), not Discrete.

help me fix an algebraic loop warning in my Simulink boost converter PI control loop

Understand the PI gain design and run the simulation

Your boost_params.m script already contains the PI gains (Kp = 0.001 and Ki = 0.5). These values were chosen using a classical frequency-domain approach.

Why these specific PI gains?

A boost converter's small-signal model contains a right-half-plane (RHP) zero that limits how fast the controller can respond. If the crossover frequency is set too high (above the RHP zero), the system becomes unstable.

The parameter script targets a crossover frequency of 700 Hz and a phase margin of 55 degrees. This keeps the loop well below the RHP zero while still giving fast enough response for EV load transients.

The proportional gain Kp is intentionally small (0.001) because the plant's DC gain is very high (Gvd_dc = 800 V per unit duty cycle). The integral gain Ki (0.5) ensures zero steady-state error by accumulating any persistent voltage offset over time.

  • Switch to the MATLAB Command Window.
  • Run your parameter script to ensure the gains are loaded into the workspace:
run('boost_params.m')
  • Return to your Simulink model and click the green Run button in the toolbar (or press Ctrl+T).
  • Open the Scope block to view the output voltage waveform.

You should see the output voltage rise from 0V and settle to 400V within approximately 20ms with minimal overshoot.

Output voltage oscillating or not settling?

Make sure you ran boost_params.m before simulating. If the workspace variables are stale or missing, the PID Controller block will use default gains instead of your designed values.

Check that the PID Controller's Controller type is set to PI (not PID). A derivative term can amplify switching noise and cause oscillations in power converters.

my boost converter output voltage is oscillating and not settling to 400V with PI control

Test with a load step disturbance

In a real EV, the driver pressing the accelerator pedal causes a sudden increase in current draw. You will simulate this by doubling the load power at t=0.05s (from 2kW to 4kW).

  • Select the fixed Resistor block in your model and delete it.
  • In the Library Browser, navigate to Simscape > Foundation Library > Electrical > Electrical Elements.
  • Drag a Variable Resistor block into your model where the fixed Resistor was.
  • Connect the Variable Resistor's + and - terminals to the same nodes that the old Resistor was connected to.

What is the Variable Resistor block?

Unlike the fixed Resistor, the Variable Resistor accepts a physical signal input (port R) that sets its resistance value during simulation. This lets you change the load dynamically to test how the controller responds.

  • Navigate to Simulink > Sources and drag a Step block into your model.
  • Double-click the Step block and configure it:
  • Set Step time to 0.05.
  • Set Initial value to R_load (80 ohms, representing 2kW at 400V).
  • Set Final value to R_load/2 (40 ohms, representing 4kW, simulating an acceleration event).
  • Click OK.
  • From Simscape > Utilities, drag a Simulink-PS Converter block into your model.
  • Wire: Step block output > Simulink-PS Converter > Variable Resistor R port.
  • Also reconnect the Voltage Sensor across the Variable Resistor (parallel connection, same as before).
  • Click the green Run button to simulate for 0.1s.
  • Open the Scope to view the output voltage.

You should see the output voltage settle to 400V in the first 20ms, then dip briefly at t=0.05s when the load doubles, then recover back to 400V within 10-20ms. The steady-state error is zero thanks to the integral term in the PI controller.

What does zero steady-state error mean?

The integrator in the PI controller accumulates any persistent difference between the reference and the measured output. Over time, it adjusts the duty cycle until the error signal is exactly zero. This guarantees the output voltage returns to precisely 400V after any disturbance.

Output voltage not recovering after the load step?

Verify that the Step block's Initial value is R_load (not R_load/2). If the values are swapped, the load decreases at t=0.05s instead of increasing.

Check that the Simulink-PS Converter feeding the Variable Resistor's R port is properly connected. A disconnected R port defaults to 0 ohms, which creates a short circuit.

my boost converter output voltage is not recovering after a load step change at t=0.05s

Your converter now holds 400V under realistic load transients. Next up, you will analyze the system's frequency-domain stability and generate portfolio-ready plots.

Analyze Performance and Generate Portfolio Plots

Your closed-loop PI controller holds the DC bus at 400V and recovers cleanly from a 2x load transient. That is the core engineering work complete.

Now you need to present this work in a format that impresses interviewers. In this step, you will capture simulation data into the MATLAB workspace, generate professional multi-panel waveform plots, and produce a Bode diagram showing your system's stability margins.

In this step, get ready to:
  • Capture simulation output and create a 3-panel waveform figure.
  • Generate a Bode plot showing phase margin and gain margin.
  • Export all results as portfolio-ready files.
Plot the key waveforms

To create professional plots, you first need to get the simulation data out of Simulink and into the MATLAB workspace. The To Workspace block captures any signal as a timeseries variable you can plot with full control over formatting.

  • In the Simulink Library Browser, navigate to Simulink > Sinks.
  • Drag three To Workspace blocks into your model.
  • Double-click the first To Workspace block. Set the Variable name to Vout_data. Connect it to the output of the PS-Simulink Converter (the Vout signal).
  • Double-click the second To Workspace block. Set the Variable name to IL_data. To capture inductor current, add a Current Sensor block (from Simscape > Electrical > Sensors) in series at the input of the Boost Converter. Connect its measurement output through a PS-Simulink Converter to this To Workspace block.
  • Double-click the third To Workspace block. Set the Variable name to D_data. Connect it to the output of the Saturation block (the duty cycle signal).
  • Run the simulation by clicking the Run button (or press Ctrl+T).

What do To Workspace blocks do?

Each To Workspace block logs its input signal as a timeseries variable in the MATLAB workspace. After the simulation completes, you can access the data using the variable name you specified (e.g., Vout_data). The default output format is timeseries, which stores both time values and signal data together.

After the simulation finishes, create the 3-panel figure by pasting the following code into the MATLAB Command Window:

%% Plot Key Waveforms - EV Boost Converter Performance
figure('Position', [100, 100, 800, 600]);

% Panel 1: Output Voltage
subplot(3,1,1);
plot(Vout_data.Time, Vout_data.Data, 'b', 'LineWidth', 1.2);
xlabel('Time [s]');
ylabel('Voltage [V]');
title('Output Voltage (Vout)');
xline(0.05, 'r--', 'Load Step', 'LineWidth', 1.5);
grid on;

% Panel 2: Inductor Current
subplot(3,1,2);
plot(IL_data.Time, IL_data.Data, 'r', 'LineWidth', 1.2);
xlabel('Time [s]');
ylabel('Current [A]');
title('Inductor Current (IL)');
xline(0.05, 'r--', 'Load Step', 'LineWidth', 1.5);
grid on;

% Panel 3: Duty Cycle
subplot(3,1,3);
plot(D_data.Time, D_data.Data, 'g', 'LineWidth', 1.2);
xlabel('Time [s]');
ylabel('Duty Cycle');
title('Duty Cycle (D)');
xline(0.05, 'r--', 'Load Step', 'LineWidth', 1.5);
grid on;

What does this code do?

  • subplot(3,1,N) divides the figure into three vertically stacked panels and selects panel N for plotting.
  • Each plot() call uses the .Time and .Data fields from the timeseries logged by the To Workspace blocks.
  • xline(0.05, 'r--', 'Load Step') draws a red dashed vertical line at t=0.05s and labels it. This marks the exact moment the load doubles from 2kW to 4kW.

You should see a figure with three panels. The top panel shows voltage dipping briefly at t=0.05s then recovering to 400V. The middle panel shows inductor current jumping as the controller increases power delivery. The bottom panel shows the duty cycle stepping up to compensate for the heavier load.

Seeing an error about undefined variables?

If MATLAB says Vout_data or IL_data is undefined, the simulation may not have completed. Check that you clicked Run after adding the To Workspace blocks. The data only appears in the workspace after the simulation finishes.

Also verify the Variable name in each To Workspace block matches exactly what the plotting code expects. Double-click each block to check.

help me debug my To Workspace block configuration

Generate the Bode plot for open-loop analysis

Interviewers want to see that you understand stability. A Bode plot showing gain margin and phase margin proves your controller has adequate stability reserves. You will construct the small-signal plant transfer function analytically and combine it with your PI controller to plot the open-loop response.

  • Create the Bode plot by pasting this code into the MATLAB Command Window:
%% Bode Plot - Open-Loop Stability Analysis
s = tf('s');

% Small-signal plant transfer function (duty-to-output voltage)
% Gvd(s) has a right-half-plane zero that limits bandwidth
Gvd = Vout * (1 - s*L/(R_load*(1-D_nominal)^2)) / ...
    (1 + s*L/(R_load*(1-D_nominal)^2) + s^2*L*C/(1-D_nominal)^2);

% PI controller transfer function
C_pi = Kp + Ki/s;

% Open-loop transfer function (controller * plant)
T_open = C_pi * Gvd;

% Plot Bode diagram with stability margins marked
figure;
margin(T_open);
grid on;
title('Open-Loop Bode Plot with Stability Margins');

What does this code do?

tf('s') creates a symbolic Laplace variable so you can define transfer functions algebraically.

The Gvd transfer function is the boost converter's small-signal duty-to-output model. It captures the right-half-plane zero that makes boost converters tricky to control.

The margin() function plots the Bode diagram and automatically marks the gain crossover frequency, phase margin, and gain margin on the plot. This is what interviewers want to see.

You should see a Bode plot with gain and phase curves. The phase margin should be around 55 degrees and the gain margin should be above 10 dB. These values confirm your controller has solid stability reserves.

Getting an error about tf or margin?

The tf() and margin() functions require the Control System Toolbox. Type ver in the Command Window and look for "Control System Toolbox" in the list. If it is missing, install it via the Add-On Explorer.

help me troubleshoot my Bode plot generation

Save your results

With both figures generated, you need to export them as image files and save the workspace data. This creates a self-contained portfolio package you can share or reference later.

  • Export the waveform figure as a PNG by running these commands in the Command Window:
% Save the 3-panel waveform figure
figure(1);
saveas(gcf, 'voltage_regulation.png');

% Save the Bode plot figure
figure(2);
saveas(gcf, 'bode_plot.png');

% Save the entire workspace for future reference
save('simulation_results.mat');

What does this code do?

figure(1) and figure(2) switch between the two open figure windows. saveas(gcf, 'filename.png') exports the current figure as an image file in your project folder.

save('simulation_results.mat') saves every variable in your workspace (parameters, simulation data, transfer functions) into a single .mat file. You can reload this later with load('simulation_results.mat') to recreate your plots without re-running the simulation.

  • Confirm all your portfolio files exist by running:
ls

You should see these files listed: boost_params.m, ev_boost_converter.slx, voltage_regulation.png, bode_plot.png, and simulation_results.mat.

Missing files in the output?

If voltage_regulation.png or bode_plot.png are missing, the figure windows may have been closed before saving. Re-run the plotting code from the previous substeps first, then run the saveas commands again.

Check that MATLAB's Current Folder is still set to EV_Boost_Converter. Files are saved to whatever folder MATLAB is currently in. You can check with pwd in the Command Window.

help me find my exported files

✔️ Awesome, I've got everything!

Great. Double check you have saved both your boost_params.m script and ev_boost_converter.slx model.

ⓧ I'd like to double check the full code

Here is the complete boost_params.m parameter script:

%% EV Boost Converter Parameters
% DC-DC Boost Converter: Battery (200V) to DC Bus (400V)
% Application: EV traction inverter DC bus supply

%% Power Stage Specifications
Vin = 200;          % Input voltage [V] - EV battery pack nominal
Vout = 400;         % Output voltage [V] - DC bus for traction inverter
Pout = 2000;        % Output power [W] - nominal load
fsw = 20e3;         % Switching frequency [Hz]
Tsw = 1/fsw;        % Switching period [s]

%% Derived Parameters
R_load = Vout^2 / Pout;    % Load resistance [ohm] = 80 ohm
D_nominal = 1 - Vin/Vout;  % Nominal duty cycle = 0.5
Iin = Pout / Vin;          % Average input (inductor) current [A] = 10A

%% Passive Component Sizing
% Inductor: sized for CCM with 30% current ripple
delta_IL = 0.3 * Iin;                      % Inductor current ripple [A]
L = (Vin * D_nominal) / (fsw * delta_IL);  % Inductance [H]

% Output Capacitor: sized for 1% voltage ripple
delta_Vout = 0.01 * Vout;                          % Output voltage ripple [V]
C = (Pout * D_nominal) / (Vout * delta_Vout * fsw); % Capacitance [F]

%% PI Controller Design
% Small-signal transfer function: Gvd(s) = Vout*(1 - s*L/(R_load*(1-D_nominal)^2))
%                                           / (1 + s*L/(R_load*(1-D_nominal)^2) + s^2*L*C/(1-D_nominal)^2)
% Right-half-plane zero frequency:
f_rhpz = (R_load * (1-D_nominal)^2) / (2*pi*L);  % RHP zero [Hz]

% Design targets
fc = 700;                    % Crossover frequency [Hz] (well below f_rhpz)
wc = 2*pi*fc;               % Crossover frequency [rad/s]
phase_margin_target = 55;    % Target phase margin [degrees]

% Plant DC gain (duty-to-output at DC)
Gvd_dc = Vout / (1-D_nominal);  % = 800 V

% PI gains (conservative initial values for stable operation)
Kp = 0.001;    % Proportional gain
Ki = 0.5;      % Integral gain

%% Simulation Parameters
Vref = Vout;        % Reference voltage [V]
t_sim = 0.1;        % Simulation stop time [s]

%% Display Summary
fprintf('=== EV Boost Converter Design Summary ===\n');
fprintf('Input: %d V (battery)\n', Vin);
fprintf('Output: %d V (DC bus)\n', Vout);
fprintf('Power: %d W\n', Pout);
fprintf('Duty Cycle: %.2f\n', D_nominal);
fprintf('Inductance: %.2f mH\n', L*1e3);
fprintf('Capacitance: %.2f uF\n', C*1e6);
fprintf('Load Resistance: %.1f ohm\n', R_load);
fprintf('Switching Frequency: %d kHz\n', fsw/1e3);
fprintf('RHP Zero: %.0f Hz\n', f_rhpz);
fprintf('PI Gains: Kp = %.4f, Ki = %.2f\n', Kp, Ki);
fprintf('==========================================\n');

Secret mission

Survive a Battery SOC Drop

In real EVs, the battery voltage is not constant. As state-of-charge (SOC) drops during a drive or during cold starts, the battery voltage sags significantly. Can your PI controller maintain 400V output when the input drops from 220V all the way down to 180V?

Clean Up Your Resources

Clean Up Your Resources

This project runs entirely on your local machine using your university MATLAB license. There are no cloud resources or ongoing costs to worry about.

Decide whether to keep your project files for future reference, or delete them to free up disk space.

Resources you used:

  • EV_Boost_Converter project folder on your Desktop (contains boost_params.m, ev_boost_converter.slx, PNG plots, and simulation_results.mat).

Keep everything running

No action needed. Choose this if you plan to continue refining your converter design, experimenting with different PI gains, or extending the model for a portfolio presentation.

  • Your EV_Boost_Converter folder stays on your Desktop with all files intact.
  • You can reopen the Simulink model anytime by double-clicking ev_boost_converter.slx or navigating to the folder in MATLAB.
  • Remember to run boost_params.m before simulating to reload workspace variables.

Pause - I'll come back to this later

Since this project is entirely local files, pausing is the same as keeping. There are no running processes or services to shut down.

  • Close MATLAB and Simulink to free up system memory.
  • Your project folder and all files remain on your Desktop for when you return.

Delete - I don't want to use this again

Remove all project files from your machine. This permanently deletes your Simulink model, parameter script, and exported plots.

  • Close MATLAB and Simulink if they are still open.
  • Delete the project folder by running the command for your operating system below.

macOS

rm -rf ~/Desktop/EV_Boost_Converter

Windows

rmdir /s /q "%USERPROFILE%\Desktop\EV_Boost_Converter"
  • Confirm the folder is gone by checking your Desktop. You should no longer see the EV_Boost_Converter folder.

Nice Work!

Nice Work!

You just designed, simulated, and validated a complete DC-DC boost converter with closed-loop voltage control for an EV powertrain. This is the exact skill set that entry-level power electronics roles at automotive and aerospace companies demand.

You've learned how to:

  • Build a DC-DC boost converter model in Simulink using the Simscape Electrical Boost Converter block with MOSFET switching, stepping 200V to 400V for an EV traction inverter.
  • Design a PI voltage controller using classical frequency-domain techniques (phase margin, gain crossover frequency) appropriate for a converter with a right-half-plane zero.
  • Validate closed-loop performance under a 2x load step simulating EV acceleration with zero steady-state error, and generate portfolio-ready Bode plots showing stability margins.
  • Secret Mission: Proved the controller maintains 400V output regulation under a 20% input voltage sag simulating battery SOC variation.

Ready to quiz yourself?