Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

NPollutants from fertilizer, pesticides, vehicular traffic, chemical spills, etc. can affect pH and bacterial levels in the soil. A large track of land is being

NPollutants from fertilizer, pesticides, vehicular traffic, chemical spills, etc. can affect pH and bacterial levels in the soil. A large track of land is being monitored by using robotic devices to take measurements of pH and bacteria levels. These measurements are being saved so results can be analyzed over time. The samples will be taken at regularly spaced intervals. For simplicity, a grid shown (20 rows, 20 columns) could represent the track of land:

As a coop student working for the company contracted to do the analysis, your job is to create two prototype programs: one in C++ and one in MatLab to show how the team could track and analyze results.

C++ Program

There are 3 input files that you will need to handle:

NewdataB.txt - New data from a recent sampling: pH and bacterial (B2) levels together. This single file has pairs of data (the 1st is pH, the 2nd is B2) for each location on the grid. (Hint: this will mean 20 rows and 40 columns of data.)

HighpHB.txt - Summary data from all prior samplings = highest pH levels at each grid location.

LowpHB.txt - Summary data from all prior samplings = lowest pH levels at each grid location.

Your boss is an environmental engineer but has some background in programming and has suggested the following steps and functions for your program:

Read in the data from the data files into 2D arrays, Newdata.txt, HighpH.txt and LowpH.txt.

One function to sort the new data, i.e. separate out pH measurements from B2 (bacterial) measurements. These files should be named: B2B.txt and pHB.txt.

Function to compare the new data (pHB) to the 2 summary data files (HighpHB.txt and LowpHB.txt). It should replace the summary data if there is a new maximum pH or new minimum pH detected at that position on the grid.

Then in a function or in main, write out two new data files with the new pH data and the new B2 data.

Note: this is a prototype only for pH. In the future, the analogous bacterial file functions would be developed.

MatLab Program

The MatLab program will only analyze and graph two of the data files (the others will be left for a future coop student to handle). The program should read the B2B.txt and pHB.txt files into MatLab. It should then:

Find the average pH for all of the data in pHB.txt and display it using a fprintf statement.

Find the maximum pH and minimum pH for all of the data in pHB.txt and display them using a fprintf statement.

Find the average B2 level for all of the data in B2B.txt and display it using the fprintf statement.

Find the maximum B2 and minimum B2 for all of the data in B2B.txt and display them using the fprintf statement.

Produce 3 graphs:

3 dimensional graph showing pH levels by location on a 20x20 grid. Recommend using a mesh plot of pH.

3 dimensional graph showing B2 levels by location on a 20x20 grid. Recommend using a mesh plot of B2.

pH vs. B2. Recommend plot(pH(:), B2(:), .)

Note: all of above graphs must have appropriate titles and axis labels.

text files

HighPHB.txt

11.5 9.8 9.8 9.8 9.7 9.6 9.5 9.5 9.4 9.2 9.7 10.2 9.6 9.6 9.5 9.5 9.5 9.5 9.5 11.5 9.8 9.8 9.8 9.7 9.6 9.5 9.5 9.4 9.2 9 8.8 8.8 8.6 8.6 8.6 8.6 8.8 9 9.2 9.4 9.8 9.8 9.7 9.6 9.7 9.9 10.1 9.2 9.2 8.8 8.7 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.8 9.7 9.6 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.6 9.6 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.6 9.6 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.7 9.6 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.8 9.7 9.6 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.8 9.7 9.7 9.6 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.8 9.7 9.7 9.7 9.6 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.9 9.8 9.7 9.7 9.6 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.5 10 9.8 9.7 9.7 9.7 9.6 9.5 9.5 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 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.5 5.5 5.5 5.5 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.5 5.5

NewdataB.txt

9.9 0.9056 9.8 1.0527 9.8 1.2527 9.8 1.1527 9.7 1.3512 9.6 1.827 9.5 2.32 9.5 2.31 9.4 1.6049 9.2 2.2047 9 2.2045 8.8 1.3512 8.8 1.4512 8.8 1.4512 8.8 1.4512 8.8 1.4512 9 2.2845 9.2 2.1047 9.4 2.2749 9.5 2.205 9.8 1.1527 9.8 1.1527 9.8 1.1527 9.7 1.4512 9.6 1.827 9.5 2.32 9.5 2.32 9.4 2.4049 9.2 1.9047 9 2.1045 8.8 1.4512 8.8 1.4512 8.6 0.9156 8.6 0.9156 8.6 0.9156 8.6 0.9156 8.8 1.4512 9 2.2045 9.2 2.3147 9.4 2.1049 9.8 1.1527 9.8 1.1527 9.7 1.4512 9.6 1.727 9.5 2.31 9.4 2.3049 9.4 2.3049 9.2 2.8047 9.2 2.3047 8.8 1.4512 8.6 0.9156 8.6 0.8156 8.4 0.5677 8.4 0.5577 8.4 0.5677 8.4 0.7577 8.6 0.9156 8.8 1.4512 9 2.3045 9.2 2.2047 9.8 1.1527 9.7 1.4512 9.6 1.827 9.5 2.31 9.4 2.3149 9.4 2.3049 9.2 2.3047 9.2 2.7047 8.8 1.4512 8.6 0.9156 8.4 0.5677 8.4 0.5577 8.2 0.3645 8.2 0.3645 8.2 0.3645 8.2 0.3645 8.3 0.4589 8.6 0.9256 8.8 1.4512 9 2.1045 9.6 1.847 9.6 1.727 9.5 2.11 9.4 2.1149 9.4 2.4949 9.2 2.3547 9 2.3045 8.8 1.4512 8.6 0.7156 8.6 0.9156 8.4 0.5577 8.2 0.3645 8 0.23 8.1 0.2896 8.2 0.3645 8.2 0.3645 8.4 0.6777 8.6 0.9356 8.8 1.4512 8.9 1.727 9.6 1.807 9.6 1.927 9.5 2.33 9.4 2.4049 9.2 2.2047 9 2.2645 8.8 1.4512 8.6 0.9156 8.6 0.8956 8.4 0.5577 8.2 0.3645 8 0.23 7.9 0.1827 8 0.23 8.1 0.2896 8.2 0.3645 8.4 0.8777 8.6 0.9256 8.9 1.627 8.9 1.757 9.7 1.2512 9.6 1.627 9.5 2.32 9.4 2.3049 9.4 2.1049 9.2 2.1647 9 2.3045 8.8 1.4512 8.6 0.9156 8.4 0.5477 8.2 0.3645 7.9 0.1827 7.8 0.1451 7.9 0.1827 8 0.23 8.2 0.3645 8.4 0.5577 8.6 0.9056 8.9 1.727 9 2.2045 9.8 1.0527 9.7 1.5512 9.6 1.827 9.5 2.3 9.5 2.3 9.4 2.2749 9.2 2.3047 9 2.3245 8.8 1.4512 8.6 0.9156 8.2 0.3645 8 0.23 7.9 0.1827 8 0.23 8.2 0.3645 8.4 0.5477 8.6 0.9156 8.6 0.9056 8.8 1.4512 9 2.1045 9.8 1.3527 9.7 1.3412 9.7 1.3512 9.6 1.827 9.5 2.3 9.4 2.3049 9.2 2.3047 9 2.3145 8.8 1.4512 8.6 0.9156 8.4 0.5677 8.2 0.3645 8 0.23 8.2 0.3645 8.4 0.6777 8.6 0.9156 8.6 0.9156 8.8 1.4512 9 2.2945 9.2 2.1047 9.8 1.2527 9.7 1.5512 9.7 1.5512 9.7 1.4512 9.6 1.827 9.5 2.28 9.4 2.3149 9.2 2.3047 9 2.3345 8.8 1.4512 8.6 0.9156 8.4 0.5877 8.2 0.3645 8.4 0.5377 8.4 0.8777 8.6 0.9156 8.8 1.4512 9 2.3045 9.2 2.3147 9.4 2.2049 9.9 0.8156 9.8 1.1527 9.7 1.4512 9.7 1.4512 9.6 1.827 9.5 2.27 9.4 2.3249 9.2 2.3047 9 2.3145 8.8 1.4512 8.6 0.9156 8.6 0.9156 8.4 0.5977 8.4 0.5777 8.6 0.9156 8.8 1.4512 9 2.1045 9.2 2.2047 9.4 2.3649 9.5 2.235 10 0.8273 9.8 1.1527 9.7 1.4512 9.7 1.4512 9.7 1.4512 9.6 1.827 9.5 2.32 9.4 2.3049 9.2 2.3247 9 2.3045 8.8 1.4512 8.6 0.9156 8.6 0.9156 8.6 0.9156 8.8 1.4512 9 2.3045 9.2 2.2047 9.4 2.0049 9.5 2.34 9.6 1.827 10 0.7973 10 0.7273 9.8 1.1527 9.7 1.4512 9.7 1.4512 9.7 1.4512 9.6 1.827 9.6 1.887 9.4 2.3349 9.2 2.3057 9 2.3045 8.8 1.4512 8.8 1.4512 8.8 1.4512 9 2.3145 9.2 2.1047 9.4 2.3049 9.5 2.3 9.6 1.827 9.7 1.4512 10.1 0.5677 10.1 0.5477 10 0.7273 9.8 1.1527 9.8 1.1527 9.7 1.4512 9.7 1.4512 9.6 1.807 9.5 2.31 9.4 2.3249 9.2 2.2147 9 2.3045 9 2.2945 9 2.3045 9.2 2.3247 9.4 2.3049 9.5 2.3 9.6 1.627 9.7 1.4512 9.8 1.1527 10.2 0.4589 10.2 0.4589 10.1 0.5677 10 0.7273 9.8 1.1527 9.7 1.4512 9.7 1.4512 9.7 1.4512 9.6 1.827 9.5 2.21 9.4 2.3149 9.2 2.2847 9.2 2.2047 9.2 2.3147 9.4 2.3049 9.5 2.21 9.6 1.727 9.6 1.747 9.7 1.4512 9.8 1.1527 10.3 0.3645 10.2 0.4589 10.2 0.4589 10.1 0.5577 10 0.7273 9.8 1.1527 9.7 1.4512 9.7 1.4512 9.7 1.4512 9.6 1.827 9.5 2.27 9.5 2.26 9.5 2.1 9.5 2.21 9.5 2.29 9.6 1.627 9.7 1.4512 9.7 1.4512 9.8 1.1527 9.9 0.9156 10.3 0.3645 10.3 0.3645 10.2 0.4589 10.2 0.4689 10.1 0.5677 10 0.7273 9.8 1.1527 9.8 1.1527 9.7 1.4512 9.7 1.4512 9.6 1.827 9.6 1.827 9.6 1.827 9.6 1.827 9.6 1.827 9.7 1.4512 9.8 1.1527 9.8 1.1527 9.9 0.9156 10 0.7273 10.4 0.2796 10.4 0.2696 10.3 0.3645 10.2 0.4589 10.2 0.4589 10.1 0.5777 10 0.7273 10 0.7273 9.8 1.1527 9.8 1.1527 9.7 1.4512 9.7 1.4512 9.7 1.4512 9.7 1.4512 9.7 1.4512 9.8 1.1527 10 0.7273 9.9 0.9156 10.1 0.5677 10.1 0.5277 10.4 0.2896 10.4 0.2496 10.4 0.2996 10.3 0.3645 10.3 0.3645 10.2 0.4589 10.1 0.5827 10.1 0.5677 10 0.7273 10 0.7273 9.8 1.1527 9.8 1.1527 9.8 1.1527 9.8 1.1527 10 0.7273 10 0.7273 10 0.7273 10 0.7273 10.1 0.5855 10.2 0.4589 10.5 0.23 10.4 0.2896 10.4 0.2896 10.4 0.2896 10.3 0.3645 10.2 0.4589 10.2 0.4589 10.1 0.5807 10.1 0.5677 10.1 0.5817 10 0.7273 10 0.7273 9.9 0.9156 9.9 0.9156 10 0.7273 10 0.7273 10.1 0.5877 10.1 0.58 10.2 0.4589 10.2 0.4589

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

MFDBS 89 2nd Symposium On Mathematical Fundamentals Of Database Systems Visegrad Hungary June 26 30 1989 Proceedings

Authors: Janos Demetrovics ,Bernhard Thalheim

1989th Edition

3540512519, 978-3540512516

More Books

Students also viewed these Databases questions

Question

Contrast parental and peer influences during adolescence.

Answered: 1 week ago