View License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from
Morse Code

4.1 | 7 ratings Rate this file 12 Downloads (last 30 days) File Size: 14.1 KB File ID: #7791 Version: 1.0

Morse Code



05 Jun 2005 (Updated )

This converts text to playable morse code in wav format.

Editor's Notes:

This file was selected as MATLAB Central Pick of the Week

| Watch this File

File Information

MORSE converts text to playable morse code in wav format.



If the wave file name is specified, then the funtion will output a wav file with that file name. If only text is specified, then the function will only play the morse code wav file without saving it to a wav file.


  morse('How are you doing my friend?','morsecode.wav');


This file inspired Morse/Demorse Unleashed and Demorse.

MATLAB release MATLAB 7 (R14)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (13)
17 Jun 2016 Antonio tenorio

genial aporte

Comment only
24 Feb 2012 Sandeep Kaur

can anyone tell me how to convert speech to text?

Comment only
29 May 2009 Esben

Esben (view profile)

Nice little useful program for training your morse skills:)

I updated the code a little, if anyone is interested... (feel free to add it to the original):

To have smaller spaces between letters, change line 33 from lsp = wav(6176:23022); to lsp = wav(6176:16022);

To add danish letters æ,ø,å (can be done for any additional signs, and I probably will later), add
AE = [Dit;ssp;Dah;ssp;Dit;ssp;Dah]; % danish Æ .-.-
OE = [Dah;ssp;Dah;ssp;Dah;ssp;Dit]; % danish Ø ---.
AA = [Dit;ssp;Dah;ssp;Dah;ssp;Dit;ssp;Dah]; % danish Å .--.-
and change
vars ={'period','comma','question','slash_'}; to
vars ={'period','comma','question','slash_','AE','OE','AA'};
and change
elseif ismember(text(i),'.,?/')
x = findstr(text(i),'.,?/');
elseif ismember(text(i),'.,?/ÆØÅ')
x = findstr(text(i),'.,?/ÆØÅ');

to modify the speed, a resampling is added in the last part (just after the loop):
morsecode=resample(morsecode,Fs,15000); % resample to Fs/15000
if the numberused is higher than Fs, the speed will be higher, if it is lower, the speed will be lower...

11 Mar 2008 Chirag Bhatt

Hi , While running this program , I found the following error,
??? Index exceeds matrix dimensions.

Error in ==> morse at 23
text = varargin{1};
My version is 7.2(R2006a)
What I have to do?

Comment only
08 Mar 2008 Chris Knox

11 Aug 2007 Elvin Hai

It's a great program! May I know how the data in the wav.mat was obtained?

30 Mar 2006 Craig Miller K3OOL

Nice program. Brute force method of generating Morse code but it works very well.

24 Jan 2006 senthil raj

hou to convert text into speech more efficiently

Comment only
16 Oct 2005 J Cea

To convert morse audio into text, do a search for "cw get"

Comment only
25 Sep 2005 mani khan

how to convert wave file to .mat extension

Comment only
19 Aug 2005 Osamah Rawashdeh

Awesome, usefull for creating ringtones for my cellphone ... ( SMS, MMS, CQ CQ CQ , etc)

17 Aug 2005 Carlo Cauyan

is there a code that does the opposite of this? convert a morse code audio into a alphanumeric message...a reply is greatly appreciated

18 Jul 2005 joe schmoe

Pretty neat, though it has little use now-a-days

08 Jun 2005

Added more description to the help section.

Contact us