Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

starter code: names = [CENTRAL OVER S&S CAN,WACKER-MICHIGAN-RAND,RYAN SB RMP TO 55WB,1.3-2.6 MI SW OF I94,MICH.AVE-S.OF RIVER, North to West Ramp,RIVER TO CANAL ST,RAMP 'G',RANDOLPH-MICHIGAN-FI,55

starter code:

names = ["CENTRAL OVER S&S CAN","WACKER-MICHIGAN-RAND","RYAN SB RMP TO 55WB","1.3-2.6 MI SW OF I94","MICH.AVE-S.OF RIVER", "North to West Ramp","RIVER TO CANAL ST","RAMP 'G'","RANDOLPH-MICHIGAN-FI","55 EB RMP TO SB RYAN","LARAMIE K2 AVE BR", "CANAL-HARRISON-TAYLO", "CANAL-MADISON-ADAMS"];

yearBuilt = [1970,1926,1962,1963,1921,2015,1962,2006,1937,1964,1956,1926,1926];

yearReconstruct = [2007,2002,1990,2000,1998,0,1989,0,1981,1997,1999,1983,1983];

score = [79,50,94.5,94,60.9,96,68,96,80.9,94.4,80.2,41.4,45.6];

opt = input('What would you like to plot (1-year built, 2-year reconstruct, 3-score? ');

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

Background: This project is designed based on the NAE's Engineering Grand Challenge of "Restore and Improve Urban Infrastructure". The data comes from the Illinois Department of Transportation. You will be visualizing a data set that contains all the bridges on record for Cook Country. 1. To start, download the starter code and save the file as project3.m. 2. Pay attention to where you are going to add your code (see comments in the starter code). This has an input prompt in it: opt = input('What would you like to plot (1-year built, 2-year reconstruct, 3-score? '); If you run the starter code, you will see what the input prompt does. In the command window, you will see the question will appear and a blinking cursor, which is waiting for user input. If you type 1 in the command window and press enter, then opt will store the value of 1 (e.g. opt = 1). If you type 2 in the command window and press enter, then opt will store the value of 2. If you type 3 in the command window and press entire, then opt will store the value of 3. Try it out and make sure you understand what is doing. 3. BASE CODE: You are going to create three branches, one for each of the three options: opt = 1 -> 2020 2010 2000 1990 1980 Year Built 1950 1940 1930 1920 RYAN SB RMP TO 55 RIVER TO CANAL ST North to West Ramp MICH.AVE-S.OF RIVE CANAL-MADISON-AR CANAL-HARRISON-T LARAMIE K2 AVER 55 EB RMP TO SB RY CENTRAL OVER S&S WACKER-MICHIGAN 1.3-2.6 MI SW OF 194 RAMP 'G RANDOLPH-MICHIGA 1920 CENTRAL OVER S&S CAN 1.3-2.6 MI SW OF 194 WACKER-MICHIGAN-RAND RYAN SB RMP TO 55WB Bridges You can recreate this figure through visual inspection, but here is a written description: marker should be red, marker should be upside down triangle, x axis should be integers, line style should be no line, line width shoudl be 2, xtick labels should be the names of the bridges, xtick labels should be rotated by -45 degrees, the x axis should be labelled, the y axis should be labeled, the grid should be on. MICH.AVE-S. OF RIVER North to West Ramp RIVER TO CANAL ST RAMPG RANDOLPH-MICHIGAN-FI 55 EB RMP TO SB RYAN LARAMIE K2 AVE BR CANAL-HARRISON-TAYLO CANAL-MADISON-ADAMS opt = 2 -> 2010 2005 2000 Year Reconstructed 1995 1990 1985 1980 WACKER-MICHIGAN-RAND CENTRAL OVER S&S CAN RYAN SB RMP TO 55WB RAMPG LARAMIE K2 AVE BR CANAL-HARRISON-TAYLO CANAL-MADISON-ADAMS 1.3-2.6 MI SW OF 194 MICH.AVE-S.OF RIVER North to West Ramp RIVER TO CANAL ST RANDOLPH-MICHIGAN-FI 55 EB RMP TO SB RYAN Bridges Vanaan roostethio ficutbraubiaulienation but bereiritton donorintiemerkorbaudhabu markarbaudhairolo V. CR S&S CAN SON-ADAMS SON-TAYLO AVE BR SB RYAN CHIGAN-FI OF RIVER OF 194 VALST Hamp TO 55WB HIGAN-RAND Bridges You can recreate this figure through visual inspection, but here is a written description: marker should be blue, marker should be a circle, X axis should be integers, line style should be no line, line width shoudl be 2, xtick labels should be the names of the bridges, xtick labels should be rotated by -45 degrees, the x axis should be labelled, the y axis should be labeled, the grid should be on. Lastly, some of the year reconstructed data is missing (because some bridges have never been reconstructed). Those years are 0 in the data set. That will mess up our plots because 0 is so much smaller than 1900+. To fix this, set all zero data to NaN (not a number). opt = 3 -> Overall Score 1.3-2.6 MI SW OF 194 RAMP 'G' CANAL-HARRISON-TAYLO CENTRAL OVER S&S CAN WACKER-MICHIGAN-RAND RYAN SB RMP TO 55WB MICH.AVE-SOF RIVER North to West Ramp RIVER TO CANAL ST RANDOLPH-MICHIGAN-FI 55 EB RMP TO SB RYAN LARAMIE K2 AVE BR CANAL-MADISON-ADAMS Bridges You can recreate this figure through visual inspection, but here is a written description: marker should be green, marker should be an 0 55WB GAN-RAND S&S CAN ump SB RYAN CHIGAN-FI RIVER 194 VE BR SN-ADAMS ON-TAYLO Bridges You can recreate this figure through visual inspection, but here is a written description: marker should be green, marker should be an asterisk, x axis should be integers, line style should be no line, line width shoudl be 2, xtick labels should be the names of the bridges, xtick labels should be rotated by -45 degrees, the x axis should be labelled, the y axis should be labeled, the grid should be on. Test your code on MATLAB. When your run your code, if you respond to the prompt with 1, 2, or 3, one of the above plots should be produced (respectively). Once you have this base code done, you can test your code here on Zybooks. Follow the instructions below and in the comments in the starter code as to what you should copy and paste into Zybooks. After finishing this step, you should be able to pass the first three test cases, if your code is correct. Before moving on, there is a style constraint on your code. The entire code you write for this project may only have the plot function called exactly one time. If I did a CTRL+f on your script file for the word 'plot', I would only see one instance of it. Additionally, I would only see one instance of xlabel and ylabel. Therefore, make sure you are avoiding repeated code by only putting code inside the branches that needs to be there, and leaving the rest outside the branching (i.e. plot, xlabel, ylabel, etc. should all be below the branches and called just one time) 4. GENERALIZE CODE: Now that your base code is done, you are going to move on to think about generalizing your code. Right now, you have produced plots for the provided four arrays of 13 bridges. But, if you wrote your code generally (did not hard code), then you code should also be able to produce plots for any names, yearBuilt, yearReconstruct, and score arrays. You can test out your code now by trying it out below with these three function calls: testit('bridgesBig.mat', 1) testit('bridgesBig.mat', 2) testit('bridgesBig.mat', 3) You will probably notice that with soo much data, it does not make sense to label the x axis with each bridge name. Therefore, you will need to add a new branch to your code to handle this case. If the number of bridges in the data is greater than 15, you should not label the x axis (and also, shouldn't rotate the labels...because they aren't any). To handle this case, simple keep the xticks, xticklabels, and xtickangle at their default values (i.e. do not call them). Once you get that branch in your code, you can test again here in Zybooks and it should pass the next three test cases. Here is what your plot should look like for opt 1 on big data: 2020 should pass the next three test cases. Here is what your plot should look like for opt 1 on big data: 2020 2000 4494 1980 1960 Year Built 1940 1920 1900 1880 100 100 200 400 500 600 300 Bridges 5. EDGE CASE: Lastly, you are going to do some error handling. There are two cases to consider: a. If the arrays are empty (no bridge data available), your code should produce a blank figure and not attempt to plot or customize anything. To do this, add another branch that nests around everything you have already written. Make sure the code your have written only gets executed for non-empty data arrays. b. If the user enters an invalid option (some other than 1, 2, or 3, provide a useful error message (like "Invalid opt value, it must be either 1, 2, or 3") and produce a blank figure (do not attempt to plot or customize anything). Here is what the empty figure should look like: Figure 1 File Edit View Insert Tools Desktop Window Help HI E O Figure 1 Insert Tools Desktop Window File Edit View Help Once your handle these edge cases, your code should pass the remaining test cases. How to submit? After testing your code thoroughly and making sure you have followed all the style guidelines in the online rubric and the rules described here...only can call plot once, etc.), submit your m file to Gradescope. Not your script file should only work for the original 13 bridge data and include the input prompt. Background: This project is designed based on the NAE's Engineering Grand Challenge of "Restore and Improve Urban Infrastructure". The data comes from the Illinois Department of Transportation. You will be visualizing a data set that contains all the bridges on record for Cook Country. 1. To start, download the starter code and save the file as project3.m. 2. Pay attention to where you are going to add your code (see comments in the starter code). This has an input prompt in it: opt = input('What would you like to plot (1-year built, 2-year reconstruct, 3-score? '); If you run the starter code, you will see what the input prompt does. In the command window, you will see the question will appear and a blinking cursor, which is waiting for user input. If you type 1 in the command window and press enter, then opt will store the value of 1 (e.g. opt = 1). If you type 2 in the command window and press enter, then opt will store the value of 2. If you type 3 in the command window and press entire, then opt will store the value of 3. Try it out and make sure you understand what is doing. 3. BASE CODE: You are going to create three branches, one for each of the three options: opt = 1 -> 2020 2010 2000 1990 1980 Year Built 1950 1940 1930 1920 RYAN SB RMP TO 55 RIVER TO CANAL ST North to West Ramp MICH.AVE-S.OF RIVE CANAL-MADISON-AR CANAL-HARRISON-T LARAMIE K2 AVER 55 EB RMP TO SB RY CENTRAL OVER S&S WACKER-MICHIGAN 1.3-2.6 MI SW OF 194 RAMP 'G RANDOLPH-MICHIGA 1920 CENTRAL OVER S&S CAN 1.3-2.6 MI SW OF 194 WACKER-MICHIGAN-RAND RYAN SB RMP TO 55WB Bridges You can recreate this figure through visual inspection, but here is a written description: marker should be red, marker should be upside down triangle, x axis should be integers, line style should be no line, line width shoudl be 2, xtick labels should be the names of the bridges, xtick labels should be rotated by -45 degrees, the x axis should be labelled, the y axis should be labeled, the grid should be on. MICH.AVE-S. OF RIVER North to West Ramp RIVER TO CANAL ST RAMPG RANDOLPH-MICHIGAN-FI 55 EB RMP TO SB RYAN LARAMIE K2 AVE BR CANAL-HARRISON-TAYLO CANAL-MADISON-ADAMS opt = 2 -> 2010 2005 2000 Year Reconstructed 1995 1990 1985 1980 WACKER-MICHIGAN-RAND CENTRAL OVER S&S CAN RYAN SB RMP TO 55WB RAMPG LARAMIE K2 AVE BR CANAL-HARRISON-TAYLO CANAL-MADISON-ADAMS 1.3-2.6 MI SW OF 194 MICH.AVE-S.OF RIVER North to West Ramp RIVER TO CANAL ST RANDOLPH-MICHIGAN-FI 55 EB RMP TO SB RYAN Bridges Vanaan roostethio ficutbraubiaulienation but bereiritton donorintiemerkorbaudhabu markarbaudhairolo V. CR S&S CAN SON-ADAMS SON-TAYLO AVE BR SB RYAN CHIGAN-FI OF RIVER OF 194 VALST Hamp TO 55WB HIGAN-RAND Bridges You can recreate this figure through visual inspection, but here is a written description: marker should be blue, marker should be a circle, X axis should be integers, line style should be no line, line width shoudl be 2, xtick labels should be the names of the bridges, xtick labels should be rotated by -45 degrees, the x axis should be labelled, the y axis should be labeled, the grid should be on. Lastly, some of the year reconstructed data is missing (because some bridges have never been reconstructed). Those years are 0 in the data set. That will mess up our plots because 0 is so much smaller than 1900+. To fix this, set all zero data to NaN (not a number). opt = 3 -> Overall Score 1.3-2.6 MI SW OF 194 RAMP 'G' CANAL-HARRISON-TAYLO CENTRAL OVER S&S CAN WACKER-MICHIGAN-RAND RYAN SB RMP TO 55WB MICH.AVE-SOF RIVER North to West Ramp RIVER TO CANAL ST RANDOLPH-MICHIGAN-FI 55 EB RMP TO SB RYAN LARAMIE K2 AVE BR CANAL-MADISON-ADAMS Bridges You can recreate this figure through visual inspection, but here is a written description: marker should be green, marker should be an 0 55WB GAN-RAND S&S CAN ump SB RYAN CHIGAN-FI RIVER 194 VE BR SN-ADAMS ON-TAYLO Bridges You can recreate this figure through visual inspection, but here is a written description: marker should be green, marker should be an asterisk, x axis should be integers, line style should be no line, line width shoudl be 2, xtick labels should be the names of the bridges, xtick labels should be rotated by -45 degrees, the x axis should be labelled, the y axis should be labeled, the grid should be on. Test your code on MATLAB. When your run your code, if you respond to the prompt with 1, 2, or 3, one of the above plots should be produced (respectively). Once you have this base code done, you can test your code here on Zybooks. Follow the instructions below and in the comments in the starter code as to what you should copy and paste into Zybooks. After finishing this step, you should be able to pass the first three test cases, if your code is correct. Before moving on, there is a style constraint on your code. The entire code you write for this project may only have the plot function called exactly one time. If I did a CTRL+f on your script file for the word 'plot', I would only see one instance of it. Additionally, I would only see one instance of xlabel and ylabel. Therefore, make sure you are avoiding repeated code by only putting code inside the branches that needs to be there, and leaving the rest outside the branching (i.e. plot, xlabel, ylabel, etc. should all be below the branches and called just one time) 4. GENERALIZE CODE: Now that your base code is done, you are going to move on to think about generalizing your code. Right now, you have produced plots for the provided four arrays of 13 bridges. But, if you wrote your code generally (did not hard code), then you code should also be able to produce plots for any names, yearBuilt, yearReconstruct, and score arrays. You can test out your code now by trying it out below with these three function calls: testit('bridgesBig.mat', 1) testit('bridgesBig.mat', 2) testit('bridgesBig.mat', 3) You will probably notice that with soo much data, it does not make sense to label the x axis with each bridge name. Therefore, you will need to add a new branch to your code to handle this case. If the number of bridges in the data is greater than 15, you should not label the x axis (and also, shouldn't rotate the labels...because they aren't any). To handle this case, simple keep the xticks, xticklabels, and xtickangle at their default values (i.e. do not call them). Once you get that branch in your code, you can test again here in Zybooks and it should pass the next three test cases. Here is what your plot should look like for opt 1 on big data: 2020 should pass the next three test cases. Here is what your plot should look like for opt 1 on big data: 2020 2000 4494 1980 1960 Year Built 1940 1920 1900 1880 100 100 200 400 500 600 300 Bridges 5. EDGE CASE: Lastly, you are going to do some error handling. There are two cases to consider: a. If the arrays are empty (no bridge data available), your code should produce a blank figure and not attempt to plot or customize anything. To do this, add another branch that nests around everything you have already written. Make sure the code your have written only gets executed for non-empty data arrays. b. If the user enters an invalid option (some other than 1, 2, or 3, provide a useful error message (like "Invalid opt value, it must be either 1, 2, or 3") and produce a blank figure (do not attempt to plot or customize anything). Here is what the empty figure should look like: Figure 1 File Edit View Insert Tools Desktop Window Help HI E O Figure 1 Insert Tools Desktop Window File Edit View Help Once your handle these edge cases, your code should pass the remaining test cases. How to submit? After testing your code thoroughly and making sure you have followed all the style guidelines in the online rubric and the rules described here...only can call plot once, etc.), submit your m file to Gradescope. Not your script file should only work for the original 13 bridge data and include the input prompt

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Analysis Using SQL And Excel

Authors: Gordon S Linoff

2nd Edition

111902143X, 9781119021438

More Books

Students also viewed these Databases questions