First, you need to download the following audio files. Save them to a folder of your choice, start Matlab and change with "cd" to that folder.
Now, go to the "File"-Menu and choose "New | M-File".
Comments start with a percentage character. The first comment block after the definition of the function will be displayed by Matlab whenever you type "help trial". So it is a very good idea to spend a little bit of your time with documentation before you write the first line of code.
% TRIAL plays either western or country.
% TRIAL(WESTERN,COUNTRY) displays a blank screen, ...
Copying the style of Matlab comments (upper-case function and variable names, short description in the first line, function parameters and a longer description indented below) will become very handy if you work a lot with Matlab or when you start extending the existing toolboxes.
To see that this really works, you may choose "Save" in the m-file window (or click on the disk), change to the main window, and after typing "help trial" you should see the documentation.
sound(country, fsc)else
sound(western, fsw)end
Then, save the file and change to the Matlab command window.
> [c, fsc] = wavread('country.wav');
> [w, fsw] = wavread('western.wav');
> trial(c, fsc, w, fsw);
:-)
Page Execution took 2.793 seconds |