{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

parseInput

# parseInput - function vec = parseInput(ca%Write a function...

This preview shows pages 1–2. Sign up to view the full content.

function vec = parseInput(ca) %Write a function, parseInput, that takes in a cell array of strings, %each representing a note on the piano. The function should return a %vector of half steps, up (+) or down (-), from middle C (C4). %Notes will be in one of two formats: either of length 2, with the note %name and octave (F3) or of length 3 with note name, sharp/flat, and %octave (G#4). Note names go in the following order: C,D,E,F,G,A,B. %When going from B to C, the octave number is incremented (so B3 and C4 %are 1 half step away, where E3 and F4 are an octave and a half step %away). %For the less musically inclined, here's a quick rundown of how you %should approach each piece of data. Refer to Piano Notes.jpg as you %read this: % - In this example we will compute how far away G#3 is from C4. % - First add the number of half-steps that seperate your note from % C- don't worry about octaves or sharps/flats. A half-step is one % piano key. So... vec = []; %initializes the output for ndx = 1:length(ca) if length(ca{ndx})==2 %determines if the chord is whole

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 2

parseInput - function vec = parseInput(ca%Write a function...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online