(New page: % Nicholas Block % ECE301 Fall 2008 % Homework #1 clear; clc; % Part A % Define frequencies % All frequencies found using equations from HW sheet B = 495; A = 440; G = 396; F = 352; E...)
 
Line 1: Line 1:
 +
==MATLAB Code==
 +
<pre>
 
% Nicholas Block
 
% Nicholas Block
 
% ECE301 Fall 2008
 
% ECE301 Fall 2008
Line 46: Line 48:
 
         Sound(d,1/delta);
 
         Sound(d,1/delta);
 
end
 
end
 +
</pre>

Revision as of 10:58, 4 September 2008

MATLAB Code

% Nicholas Block
% ECE301 Fall 2008
% Homework #1

clear;
clc;

% Part A

% Define frequencies
% All frequencies found using equations from HW sheet

B = 495;
A = 440;
G = 396;
F = 352; 
E = 330;
D = 297;
C = 264;

% Define note durations
% Assuming bpm=135

% Quarter note
Qn = 60/135;
% Eighth note
En = Qn/2;
% Half note
Hn = Qn *2;
% Whole note
Wn = Qn *4;

% Sample rate
delta = 1/44100;

% Melody

notes = [G, A, B, C, D, E, E, F, F, F, C, D, E];
rhythm = [Hn, Qn, Qn, Qn, En, Qn, Qn, Qn, En, En, Qn, Qn, Hn];

% Regular time

for counter=1:13
        t=0:delta:rhythm(counter);
        d=sin(2*pi*t*notes(counter));
        Sound(d,1/delta);
end

Alumni Liaison

To all math majors: "Mathematics is a wonderfully rich subject."

Dr. Paul Garrett