File Exchange

image thumbnail


version (6.05 MB) by Matt Brauer
Enigma M3 Emulator


Updated 12 Oct 2017

From GitHub

View license on GitHub

Editor's Note: This file was selected as MATLAB Central Pick of the Week

Enigma M3 Emulator
This is a MATLAB App for simulating the Enigma encryption machine. It specifically emulates the M3 variant of the machine used during World War II by the German army.
To run the app, type the following at the MATLAB command prompt:


Perform encryption/decryption by clicking on the round keys at the bottom of the machine. Your input and the machines output will be recorded on the tablet on the right of the App. Keyboard input can also be used.

You can configure the machine in a variety of ways. Click the rotor icon on the top-right of the machine to modify the :
•rotor types
•ring offsets of the rotors
•reflector type
•plugboard connections

You can also modify the position of the rotors by hovering over the rotor images and using the scroll-wheel of the mouse or dragging up or down with the left mouse button pressed.

You can also run the simulation completely from the MATLAB command line. See the startHere.m file for a demonstration.

Related links:
Alan Turing and His Connections to MATLAB

The Enigma Machine and MATLAB

Contributors to this App were Corey Lagunowich, Cesar Rivadeneyra, Adam Sifounakis and Sean de Wolski

Cite As

Matt Brauer (2021). Enigma (, GitHub. Retrieved .

Comments and Ratings (14)



Hans Wyssmann


I am new to Mathlab. I have downloaded the folder mathworks-Enigma-cdb1a4c. How do I launch the app ? Do I have to move the folder to some place ?

Thank you for your help


Dave Polidori

@MattBrauer -- thanks, that solved my problem. Love the program. Great work.

Matt Brauer

@Dave Polidori, it looks like a version compatibility problem. Please apply the suggestion from Yaroslav's comment (26 Oct 2015)


@Matt Brauer Thank You for the answer/clarification. I have tried (earlier) the way You mentioned, but it was still not working for me. Even, I had problems if all folders were not in the "C:\Users\[Your User Name]\Documents\MATLAB", but in some sub-folder... Possible problem on my side - in my installation folder/conflict.

Anyway, now is working, and I sincerely am amazed how You authors had made it. For every respect. figuring out how Enigma works is a pretty difficult task - even with today explanations from many sources on web... BUT, make it work flawlessly under MATLAB, it is for every respect. Once more, thank You all for the great coding and application.

Matt Brauer

@Teodo, sorry to hear that you had problems getting the app running. To clarify, it's not necessary to run the app from MATLAB's root folder. It's only necessary to run the app while your current working directory (what is returned by PWD and shown in the top navigation bar) is the parent directory of the app.

Dave Polidori

I can't figure out how to get this to work. If someone can help me, I would appreciate it. My 9 year old son is doing a report on Alan Turing and this would be great for him.

I tried on both a Mac and a PC and I keep getting error messages about not finding files or other issues. On the Mac, I moved the mathworks-Enigma-cdb1a4c folder into the MATLAB folder, added it to the path, and changed the working directory to be that folder. When I launch the app, I get this warning:

Error using drawnow
Unknown command option.

Error in enigmaApp/createFigure (line 29)

Error in enigmaApp/createMachineSection (line 17)

Error in enigmaApp (line 162)

Error in launchEnigma (line 7)


I grasped with the problem for hours now... trial and error method. :-) Problem solved, sorry to bother You before. Please delete my comment - if not needed by others.

Solution: You must put ALL the app files in ROOT folder: "C:\Users\[Your User Name]\Documents\MATLAB", and of course - add it to main path (if it is not already in default path location). Files must not be in the originating folder, but rather only in root of the main path. It is NOT enough to add some other folder as a path! At least, it was for me like that, and Windows 7 Ultimate OS. Furthermore, there is a problem adding - to the path, the folder named: "images" - even if you add it to path correctly.

Thank You (to ALL authors), for the great app, in GUI as well!


This is a great app, and thank You for sharing. i have tested in the command window, but still having problems to start it in GUI mode. Even, with the version of 18.02.2016. All the paths and sub-folders are added correctly, and again, the app in M3 emulator mode is working flawlessly. I am using Matlab 2015b Academic License.

Now, the output in command window is the following:


>> launchEnigma
Error using imread (line 349)
File "@enigmaRotorUI\images\blankGauge.png" does not exist.

Error in enigmaApp/createRotorSection (line 14)
img = imread(fullfile('@enigmaRotorUI','images','blankGauge.png'));

Error in enigmaApp/createMachineSection (line 19)

Error in enigmaApp (line 162)

Error in launchEnigma (line 7)
enigmaApp; "

Can You help me please? Would really love to see this app in GUI mode, where MATLAB is under the hood (engine).

Thank You in advance.


Diego Renza Torres

Matt Brauer

As pointed out in a MATLAB Answer question, the app uses relative paths to define the location of certain images. This requires that MATLAB's working directory is the parent directory of the application's files (where launchEnigma.m resides). We will track this issue on the Git repository and look at submitting an enhancement. Sorry for the inconvenience.

Muthu Annamalai



This is a great app. Excellent to learn good OOP and GUI practices with MATLAB.

Just a small compatibility issue: in @enigmaApp/resizeFigureToFitScreen.m the line
<code> drawnow('limitrate','nocallbacks')
should be replaced with
try % MATLAB 2015b
catch % Earlier Matlab releases
in order to work with MATLAB R2014b.

MATLAB Release Compatibility
Created with R2015a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!