Question: Ask someone over 40 what a Compact Disc is, and then write a function with the header: function [CD] = myMusicCollection(genre, title, artist, year, stars,

Ask someone over 40 what a Compact Disc is, and then write a function with the header:

function [CD] = myMusicCollection(genre, title, artist, year, stars, CD)

which adds a new CD to an existing data structure with fields genre (a string), title (a string), artist (a string), year (a double), and stars (a double) and returns the updated data structure. This function will only work if CD already has at least one album.

Test Cases:

>> CD.genre = 'Classical';

>> CD.title = 'Mass in G';

>> CD.artist = 'Bach';

>> CD.year = 2004;

>> CD.stars = 3.5;

>> CD = myMusicCollection('Classical', 'Symphony 40', 'Mozart', 2015, 4, CD);

>> CD

CD =

1x2 struct array with fields:

genre

title

artist

year

stars

>> CD(1).title

ans =

Mass in G

>> CD(2).year

ans =

2015

>> CD = myMusicCollection('Baroque', 'Rosary Sonatas', 'Biber', 2012, 4, CD);

>> CD

CD =

1x3 struct array with fields:

genre

title

artist

year

stars

>> CD(3).title

ans =

Rosary Sonatas

Deliverables: Submit the above m-files (separately, not zipped) onto Blackboard.

Be sure that the functions are named exactly as specified, including spelling and case.

You will get zero credit for a function if it is named wrong, even if

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!