songParser - % artist nor the title will contain a colon....

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
% 9/21/2009 11:30 PM % Function Name: songParser % Input: a cell containing various data data in no particular order % Outputs: 1. Title - string containing the title of the song % 2. Artist - string containing the artist of the song % 3. Length - string containing the length of the song % 4. Rank - double of the highest rank on music charts, 0 if not % ranked % 5. Single - logical, true if the song was a single, false if % not % % Function Description: % Given a cell containing information about a song, parse out: % - the title of the song % - the name of the artist % - the length of the song % - its highest rank on music charts % - if it was released as a single % % The title of the song will contain the substring 'Title-' which needs % to be removed. The time will always have a colon (:) in it; neither the
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: % artist nor the title will contain a colon. There is no order to the % input of the cell so you will have to test for each case individually. % function [ title artist length rank single ] = songParser(info) title = ''; artist = ''; length = ''; rank = 0; single = false; for r = 1:5 if islogical(info{r}) single = info{r}; elseif strcmp(class(info{r}), 'double') rank = info{r}; else % cell contains a string so it could be title, artist or length if size(strfind(info{r}, ':')) == 1 % cell contains the value for length length = info{r}; elseif size(strfind(info{r}, 'Title-')) > 0 % cell contains title title = info{r}(7:end); else artist = info{r}; end end end end...
View Full Document

This note was uploaded on 10/22/2009 for the course CS 1371 taught by Professor Stallworth during the Fall '08 term at Georgia Institute of Technology.

Ask a homework question - tutors are online