Part 2: MATLAB
Exercise 1 (50 pts)
Write a program that tells the user if a city of their choice isin a tropical, temperate, or polar region. Use the cities.txt fileprovided in the Files section of this class. Your program shouldread the data in that file, find the city given by the user, andreturn a text message with the information. If the city is notfound, your program should write a message accordingly. To decidewhich region each city falls into, use the table below.
Latitude | Region |
Above 66 N | Polar |
Between 35 N and 66 N | Temperate |
Between 35 S and 35 N | Tropical |
Between 35 S and 66 S | Temperate |
Below 66 S | Polar |
HINT: If you follow the file reading methods explained in ourvideo tutorial, your data will be in cell format. There are a fewfunctions that could be very useful in this case: strcmpcompares two strings (one of which can be in a cell) to see if theymatch. Also, cell2mat converts a cell array into anordinary array. Finally, find finds indices and values ofany non-zero elements in an array.
See the output examples below:
What city are you interested in? CaracasCaracas is in a tropical region What city are you interested in? MercedCity not found!
https://catcourses.ucmerced.edu/files/1587454/download?download_frd=1