Question: Below is the code that I have tried for this problem. So, it hasn't worked and I am confused while debugging. I am a beginner

Below is the code that I have tried for this problem. So, it hasn't worked and I am confused while debugging. I am a beginner coder and would appreciate any insights and assitance with this problem. Thanks!
function sls_sortStations(info) openInfo = fopen(info,'r'); % finding the name of the info file excluding the file format abbreviation % and creating a file whose name is the orginal text file name with % " _sorted " appended before the file format abbreviation. [name] = strtok(info,'.'); txtFile = sprintf('%s_sorted',name); txtFile = fopen(txtFile,'w'); % initializing a place holder vector to hold each station's user info stationUser = []; for i = openInfo % retrieving station information from each line of the text file for stationInfo = fgetl(openInfo) % retrieving station information from each line of the text file stationInfo = fgetl(openInfo); % extracting the user information which occurs after the ':' users = extractAfter(stationInfo,':'); % removing the spaces from the string of users users(users == char(32)) = []; % concatenating each station's users to create one list of all the users stationUser = [stationUser users ' ']; end % converting character vector of station users an into doubles in % order to sort in descending order stationUser = fliplr(sort(stationUser)); end % initializing the place holder vector that will hold each line of the % text file in the sorted order positions = []; % looping through each value of the sorted station user vector for u = 1:length(stationUser) % converting back to character vector inorder to compare with lines % of the original text file stationUser = num2str(stationUser); % looping through every line of the orginial text file once more for i = openInfo % retrieving station information from each line of the text file stationInfo = fgetl(openInfo); % if the orginal text file line contains the station user value at the % specific index, it will take its place in the positions vector. if contains(string(stationInfo),string(stationUser(u))) == true positions = [positions stationInfo ' ']; end end % creating a variable in the workspace to output the positions, making % sure to add a new line after each position has been considered. positions = sprintf('%s ',positions); end % making sure each line of text will print to the specified text file. fprintf(txtFile,'%s',positions); % printing to the desired text file. fprintf(txtFile,' '); % close the text file. fclose(txtFile); end
Homework 5- Low Level File IVO Function Name: sls_sortstations Inputs: 1. (char) Name of a file containing station info File Outputs: 1. File with stations sorted by most users Background As part of Georgia Tech's Serve, Learn, and Sustain program, you have been tasked with analyzing data from MARTA, the public transit system of the metro Atlanta region. You have been given a text file with several MARTA bus and train stations, but they're a completely random order!. You think it'd be more helpful to have them sorted in order of use, so you decide to turn to MATLAB to help you. Function Description: The text file will contain the list of stations and the number of visitors to each station in a single day. Each line of the text file will be formatted as follows Station
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
