subject

Use MATLAB 1. Basic structure: As a first step, write a program that prompts the user for the type of acid, and then uses a switch-case structure to provide the following outputs in response. If the user enters 'strong', then the program outputs 'Very low pH'. If the user enters 'weak', then the program outputs 'Moderately low pH'. For any other response, the program outputs 'Please enter strong or weak.' Paste your code on the answer sheet, along with evidence that your program operates successfully. Note: remember to use the 's' argument with the input function to allow string input by the user. For example:
AcidType = input('Please enter strong or weak for the acid type: ', 's');
2. Strong Acid pH: Next, modify the section of the program for the strong acid to correctly calculate the pH according to Equation (1). First, prompt the user to enter the acid concentration [HA], and then calculate and output the pH. Remember that for a strong acid, [H+] = [HA]. Test your program using [HA] = 0.1, then [HA] = 0.001, and finally [HA] = 0. What about [HA] = –1?
There are actually two different types of problems revealed above. In addition to generating a mathematical error (log of -1), it is physically unreasonable to have a negative concentration, and yet there is nothing to prevent a user from entering such a value.
A different type of problem exists with [HA] = 0. It is possible to have zero acid concentration (i. e., pure water). But in addition to the mathematical problem of trying to calculate log10 (0), the pH of a solution with zero acid should be perfectly neutral, or pH 7.0. In fact, to be physically accurate, anytime that such an acid calculation (for strong or weak acids) produces an [H+] value much less than 10-7 (or 1e-7), the acid has no real effect on the pH of the solution, and it should therefore be reported as a neutral pH = 7.00.
On the answer sheet, write the pseudocode for this portion of the program, incorporating an if-elseif-else structure that will correct the logical problems described above (HA < 0 and HA < 1e-7) and deal with them appropriately. Program and test your algorithm.
3. Weak Acid pH: Now, modify the section of the program for the weak acid. You will need to prompt the user for both [HA] and Ka, and use them to calculate and return the pH of the solution according to equations (3) and (1).
a) You will need to use a similar approach for dealing with user inputs of negative [HA] values; however, the weak acid case requires that you test for <1e-7 values of [H+] after x is calculated in the quadratic formula. Write the pseudocode on the answer sheet.
After programming the algorithm, test it using a typical value of Ka = 1.8 x 10-5 (represented in MATLAB as 1.8e-5) and with [HA] = 0.1, then 0, then -1. Ensure that the output is appropriate for all 3 cases.
b) Next, try testing your function with Ka = -1 and [HA] = 0.1. What happens? Again, in addition to a mathematical/logical error, it makes no physical sense to have negative Ka values. Incorporate an elseif structure to control this user input error along with your previous [HA] error control, and test the program to ensure that it works properly.
4. Menu and Plot: Convert your switch-case structure to a menu structure. In addition to Strong Acid pH and Weak Acid pH buttons, also include a button for Acid pH Plot.
After first verifying that the Strong and Weak options still function properly, program the Plot option to prompt the user for a Ka value (control for negative inputs), and then generate a plot of pH versus [HA] for acid concentrations ranging from 0.01 to 1.0 M. Include the Ka value in the title of the plot. Test your plot option for various values of Ka.

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 23:30
What are some ways to use a range name in a formula? check all that apply. in the defined names group, click use in formula, and then select the desired name. begin typing the name in the formula, select a name from the autocomplete list, and use the arrow keys and tab key to enter the name in the formula. begin typing the formula, and then click and drag with the mouse to select the cells to include in the formula. right-click one of the cells in the range. click formula options, and use the dialog box to add the name.
Answers: 1
question
Computers and Technology, 23.06.2019 01:10
Are special combinations of keys that tell a computer to perform a command. keypads multi-keys combinations shortcuts
Answers: 1
question
Computers and Technology, 23.06.2019 15:00
Barbara is interested in pursuing a career in the science and math pathway. which qualifications will her reach that goal? a.an advanced knowledge of physics and math b.an advanced knowledge of engineering and math c. an advanced knowledge of physics and robotics an d. advanced knowledge of machinery and math
Answers: 1
question
Computers and Technology, 24.06.2019 00:00
Which tool could be used to display only rows containing presidents who served two terms
Answers: 3
You know the right answer?
Use MATLAB 1. Basic structure: As a first step, write a program that prompts the user for the type...
Questions
question
Mathematics, 29.01.2020 13:54
question
History, 29.01.2020 13:54
Questions on the website: 13722367