Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

please help me with this code, it is for matlab... please only help if you know

ID: 2088086 • Letter: P

Question

please help me with this code, it is for matlab... please only help if you know how to do it 100% and it runs

Problem 3. Create a function to make a database (Structure array) containing a musical artist's information. This database will include the artist's name, an album name, the number of songs on the album, the duration of the album in minutes, and the year it was released (five fields in total). The database will contain string and numeric data types. - Output: A script will call the function and save the entered information into a structure array. The script will return this structure array once the function has completed.

Explanation / Answer

The matlab code contains a 'main' script and 'artistInfo.m' function. The main script takes in the values entered by the user and calls the 'artistInfo.m' function. At the end it displays all the entered values in the command window.

Matlab code:

main.m:

%Matlab script to call the function that creates a structure with artist's
%details

clear all

contin = 'Y';

%Collect data from command window
while(contin == 'Y')
    artName = input('Enter the musical artists information. Artist Name:','s');
    albName = input('Album Name:','s');
    numSong = input('Number of songs on the album:');
    durMin = input('Duration of album in minutes:');
    yearRelease = input('Year of release:');
    contin = input('Do you want to continue entering details about the new album/artist? Enter Y to continue or any other key to stop','s');
    if contin ~= 'Y'
        contin = 'N';
    end

    str = artistInfo(artName,albName,numSong,durMin,yearRelease);
end

%Display the entered details in order
for n = 1:length(str)
    str(n)
end

%End of main script

artistInfo.m:

% Function to create structure array
function str = artistInfo(artistName,albumName,No_songs,durationMins,year)
persistent i
persistent s

if isempty(i)
    i = 0;
end

i = i+1;

%Save values into structure field
s(i).ArtistName = artistName;
s(i).AlbumName = albumName;
s(i).Number_of_Songs = No_songs;
s(i).Duration_in_Mins = durationMins;
s(i).Year_of_Release= year;

str = s;
end