Project 4: Bridges & Branches Bridges & Branches CS 109 Spring 2021 Project 4 Summary Project Objectives Project Setup Project Implementation Part 1: User Input Part 2: Call the Function Part 3:...

1 answer below »
assignment


Project 4: Bridges & Branches Bridges & Branches CS 109 Spring 2021 Project 4 Summary Project Objectives Project Setup Project Implementation Part 1: User Input Part 2: Call the Function Part 3: Creating an empty figure Part 4: Importing the .mat Part 5: Plotting & Branches No Other Functions Only One Call To: plot, xlabel, ylabel Generalizing Code for Big Data Wrap Up Covering the Edge Cases Submission & Grading Submission to zyBooks Submission to Gradescope Style Grading Copyright Notice Attributions Summary 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. Project Objectives This project will further student understanding of the following MATLAB concepts: ● Using MATLAB Docs ● usage of .mat files ● basic function implementation ● plotting ● plot characteristics ● conditional expressions ● branches ● arrays ● array indexing Project Setup To set up the project acquire the starter code and the project's three provided .mat files for testing. 1. Use the project's starter code to create a new script within MATLAB and name it project4.m. 2. Read through all the project instructions before implementing any steps. It is always good to understand or at least know what the entire project is prior to implementing the first part. This way you know all the pieces and don't accidentally implement an early part that will not play nice with later parts and force you to redo work. http://www.engineeringchallenges.org/challenges/infrastructure.aspx http://www.engineeringchallenges.org/challenges/infrastructure.aspx http://apps.dot.illinois.gov/bridgesinfosystem/search.aspx https://www.mathworks.com/help/ https://drive.google.com/drive/folders/12_wQ67CDtSbE0J9PdW8XEXE2hk-xJacB?usp=sharing Project Implementation Part 1: User Input Obtain a value from the user. Valid values will be 1, 2, and 3. You will check validity later in the program. Part 2: Call the Function As this part of your code you must call the function you will be implementing the inner workings of. Recall a function call simply uses the function name and provides any necessary inputs. The function name is bnbTester and it takes two inputs, a string literal that is the .mat file name and the option value that you just acquired via user input in the previous step. At final submission of your code to Gradescope, your Part 2 should use bridgesSmall.mat so that it runs the small data set by default for the graders. Part 3: Creating an empty figure At times during this program's execution the user input or data may be invalid. This will yield an empty figure without a plot on it. We can do this by calling the figure function at the beginning of our function and then if nothing else executes in our function we will be left with an empty figure. Part 4: Importing the .mat The project's .mat file has all the data for plotting within it. One of the function inputs is a string literal value that contains the file name of the .mat you should use. Three .mat files are provided so that you may test your code with various data sizes. At final submission of your code to Gradescope, your Part 2 should use bridgesSmall.mat so that it runs the small data set by default for the graders. Part 5: Plotting & Branches The remainder of your code implements the plotting with the various customizations and implementation constraints outlined in these instructions. You are going to create three branches, one for each of the three options. option of 1 yields: You can recreate this figure through visual inspection, but here is a written description: ● marker should be red ● marker should be upside down triangle ● line style should be no line ● marker size will be 10 ● x axis should be integers ● the x axis should be labeled ● the y axis should be labeled ● line width should be 2 ● xtick labels should be the names of the bridges ● xtick labels should be rotated by -45 degrees ● the grid should be on Test your code on MATLAB When you run your code, if you respond to the prompt with 1 the above should appear. option of 2 yields: You can recreate this figure through visual inspection, but here is a written description: ● marker should be blue ● marker should be an asterisk ● line style should be no line ● marker size will be 10 ● x axis should be integers ● the x axis should be labeled ● the y axis should be labeled ● line width should be 2 ● xtick labels should be the names of the bridges ● xtick labels should be rotated by -45 degrees ● the grid should be on For this option, 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). Test your code on MATLAB When you run your code, if you respond to the prompt with 2 the above should appear. option of 3 yields: You can recreate this figure through visual inspection, but here is a written description: ● marker should be green ● marker should be a period ● line style should be no line ● marker size will be 10 ● x axis should be integers ● the x axis should be labeled ● the y axis should be labeled ● line width should be 2 ● xtick labels should be the names of the bridges ● xtick labels should be rotated by -45 degrees ● the grid should be on Test your code on MATLAB When you run your code, if you respond to the prompt with 3 the above should appear. Implementation Constraints No Other Functions You may not write any other functions besides the bnbTester one. Only One Call To: plot, xlabel, ylabel The entire code you write for this project may only have the plot function called exactly one time. This means if the grader performs a find (ctrl+f) on your script file for the word 'plot', the grader will only see it once. Additionally, I would only see one instance of xlabel and ylabel. Therefore, make sure you are avoiding repeated code by only placing what should be in the branches inside them and leaving the rest outside the branches. Failure to abide by these constraints will result in a maximum score of 0. Testing within MATLAB and zyBooks When you 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 on Zybooks. Follow the instructions in the comments of the starter code to know what you should copy and paste! If your code is correct, your basic code should now pass the first three test cases on zyBooks. Generalizing Code for Big Data Once 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 all sizes of names, yearBuilt, yearReconstruct, and score arrays. You can test out your generalized code now by trying it with these three function calls on zyBooks: bnbTester('bridgesBig.mat', 1) bnbTester('bridgesBig.mat', 2) bnbTester('bridgesBig.mat', 3) You will probably notice that with so 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, should not rotate the labels (because they aren't any). To handle this case, simply 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 on zyBooks then submit, and your code should pass the next three test cases. Here is what your plot should look like for option 1 on big data: Wrap Up Covering the Edge Cases Lastly, you are going to do some error handling. There are two cases to consider: 1. 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 you have written only gets executed for non-empty data arrays. 2. If the user enters an invalid option (something other than 1, 2, or 3) then you should provide a useful error message (e.g. "Invalid input value, input must be either 1, 2, or 3") and produce a blank figure (do not attempt to plot or customize anything). Once you handle these edge cases, your code should pass the remaining test cases. Below is what the empty figure should look like, locally and online within Mathworks website. Locally Online on Mathworks MATLAB Submission & Grading You must submit the same final code to both zyBooks and Gradescope. The autograder will check some of your plotting, but not all. Your plot should match the examples exactly (visually). Your plot and other items within your code will be graded manually on Gradescope, so please keep in mind that the test cases within zyBooks are not exhaustive. Submission to zyBooks You may submit your code as many times as you need. Be sure to only copy the portions stated within the comments of the starter code. When you have passed all the tests or as many as you believe you can pass, proceed with submitting your final code on Gradescope. Submission to Gradescope Go to gradescope.com or follow the link from Blackboard or Piazza. Required Submission Files: project4.m Style Grading Style is the readability of your code. As we progress through the semester, style will become important to help reduce the amount of time debugging your code as poor style can quickly lead to syntax errors and code misinterpretation. For project 4 the following will be checked: 1. Your submission has a proper comment header. 2. Your submission has visible white space allowing another person to easily read the code you have submitted. This whitespace could include but is not exclusive to blank lines between implementation steps, spacing around mathematical operations and assignments. 3. Your code should contain useful human readable comments that help explain in your own words what code blocks (multiple lines of code) do. 4. Your code does not produce excessive superfluous output. (remember your semicolons) Copyright Notice Copyright 2021 Adam Koehler
Answered Same DayFeb 28, 2021

Answer To: Project 4: Bridges & Branches Bridges & Branches CS 109 Spring 2021 Project 4 Summary Project...

Rahul answered on Mar 01 2021
136 Votes
function plot = bnbtester(b,a)
load(b,'score');
load(b,'names');
load(b,'yearBuilt');
load(b,'ye
arReconstruct');
if (a==1)&&(~isempty(score))&&(~isempty(names))&&(~isempty(yearBuilt))&&(~isempty(yearReconstruct))
x=names;
z=categorical(x);
y=yearBuilt;
d=size(z);
if d(1,1)>15
e=size(y);
f=[1:e(1,1)];
scatter(f,y,10,'v','r')
grid on;
else
scatter(z,y,10,'v','r')
ylabel('Build Year');
xlabel('Chicago...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here