Transcribed TextTranscribed Text

1. (Upload as Source) An advantage of programming is the ability to perform millions of calculations and dump it to a file for plotting. This can be extremely useful for engineers if they are simulating or characterizing a system. Below you will calculate data, write it to a file, and plot the contents in excel. a. Create a comma separated values file for writing. This can be done by creating a file with the open method as we have done in class but with a *.csv extension on the file name . For example:โ€œequation.csvโ€); b. Write a function which accepts t as an input and returns the result of the function: ๐‘ฆ = ๐‘’ โˆ’๐‘ก 1.5 โ„ โˆ— cos(๐‘ก) c. Write a loop that increments an t value by .01 from 0 to 9 d. Within that loop, for every value of t, call the function created in step b, and store the result. e. Now write your data to the csv file. The goal is to plot the information in excel, which means that in the first column we shall have our x values, and the second column the calculated y values. The format of a cvs file states that every comma denotes the end of the contents in a given column. A newline denotes a new row. Thus 12,3,8 4,6,9 will be saved in excel as: 12 3 8 4 6 9 Therefore, print the t value followed by a comma and the corresponding y value on a line for each calculation to a your csv file. It should look something like the following. 0,1 0.01,0.993306 0.02,0.986558 0.03,0.979758 0.04,0.972907 f. Finish the rest of the steps for your file IO. g. Find the file, and open it with excel. Good news, excel 2010 an up inherently knows how to parse the file. Otherwise, you may have to select comma delimited. h. Take your two columns of data and plot them using a scatter plot. It should look like the following: i. Convert the file from a csv file to an excel workbook file, xlsx, through the save as dialog box. j. Submit your program and corresponding excel workbook. 2. (Upload as Source)Two different power supplies are being tested by engineers. To test, the engineers placed each power supply under load and measured the output of the power supply. The ideal power supply should maintain an output of 12 volts regardless of the load applied. The results of the tests are were stored in the voltages.txt file which was supplied in the dropbox folder. Each line in the file represents a voltage measurement, and contains two numbers. As pictured below, the first number is the unit under test, and the second number is the voltage reading. There are 1000 readings for each unit. Figure 1 Input File -0.4 -0.2 0 0.2 0.4 0.6 0.8 1 1.2 0 2 4 6 8 10 f(t) t Series1 Do the following. a. Create two arrays to store the voltage readings for each unit. b. Read in the voltage readings from the file, and store them in the arrays created in the previous step. c. Display the number of readings taken from each unit under test. d. Calculate the average voltage for each unit under test, and display it to the console. e. Calculate the standard deviation for each unit under test and display it to the console. Use the equation below. Figure 2 Standard Deviation Equation n: is the number of samples xi: is the current sample ๐‘ฅฬ…: is the average s: standard deviation f. If you have completed the calculations correctly, you should have the results shown below. 3. Based on the results computed in the question above, which power supply is better and why?

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

int main(int argc, char** argv) {

    fstream outFile;"equation.csv", ios::out);
    if (outFile.is_open()) {
       double t = 0;
       while (t <= 9.0) {
            t += 0.01;
    return 0;

By purchasing this solution you'll be able to access the following files:

for this solution

or FREE if you
register a new account!

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Visual Basic Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Upload a file
Continue without uploading

We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats