(New page: == General Tips == When dealing with multimedia in MATLAB it is always a good idea to end every command with a semicolon. Use <pre> [data, sample_rate, bits_per_sample] = wavread('c:\pat...) |
|||
Line 15: | Line 15: | ||
Start every MATLAB program with the command clear and clc. | Start every MATLAB program with the command clear and clc. | ||
+ | <pre> | ||
+ | # clear memory | ||
+ | clear | ||
− | clear | + | # clear console |
− | clc | + | clc |
+ | </pre> | ||
== Useful Commands == | == Useful Commands == | ||
− | Functions for interacting with wav files: | + | ==== Functions for interacting with wav files ==== |
+ | <pre> | ||
+ | #Read a wav file: | ||
+ | [data, sample_rate, bits_per_sample] = wavread('c:\path\to\file\filename.wav'); | ||
+ | </pre> | ||
+ | <pre> | ||
+ | #Play the data from a wav file: | ||
+ | wavplay(data, sample_rate); | ||
+ | sound(data, sample_rate); | ||
+ | </pre> | ||
+ | <pre> | ||
+ | #Save a wav file: | ||
+ | wavwrite(data,sample_rate,bits_per_sample,'/path/to/file/filename.wav'); | ||
+ | </pre> | ||
+ | ==== Reverse the data in a vector ==== | ||
+ | <pre> | ||
+ | # Reverse a row vector | ||
+ | row_vector = flipud(row_vector); | ||
− | + | # Reverse a column vector | |
− | + | col_vector = fliplr(col_vector); | |
+ | </pre> | ||
− | + | ==== Convert a row vector to a column vector and vice versa ==== | |
− | + | <pre> | |
− | + | #Convert a column vector to row vector. | |
+ | row_vector = rot90(col_vector); | ||
− | + | #Convert a row vector to a column vector. | |
− | + | col_vector = rot90(row_vector); | |
− | + | </pre> | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | Convert a row vector to a column vector | + | |
− | + | ||
− | + |
Revision as of 07:10, 3 September 2008
Contents
General Tips
When dealing with multimedia in MATLAB it is always a good idea to end every command with a semicolon. Use
[data, sample_rate, bits_per_sample] = wavread('c:\path\to\file\filename.wav');
instead of
[data, sample_rate, bits_per_sample] = wavread('c:\path\to\file\filename.wav')
A semicolon keeps MATLAB from echoing the output of a command to the console window. Use a semicolon if you do not want to wait for 10s worth of data sampled at 44100 samples per second scroll by your screen.
Start every MATLAB program with the command clear and clc.
# clear memory clear # clear console clc
Useful Commands
Functions for interacting with wav files
#Read a wav file: [data, sample_rate, bits_per_sample] = wavread('c:\path\to\file\filename.wav');
#Play the data from a wav file: wavplay(data, sample_rate); sound(data, sample_rate);
#Save a wav file: wavwrite(data,sample_rate,bits_per_sample,'/path/to/file/filename.wav');
Reverse the data in a vector
# Reverse a row vector row_vector = flipud(row_vector); # Reverse a column vector col_vector = fliplr(col_vector);
Convert a row vector to a column vector and vice versa
#Convert a column vector to row vector. row_vector = rot90(col_vector); #Convert a row vector to a column vector. col_vector = rot90(row_vector);