Please edit my MATLAB coding to include/fix the missing lines of coding that will satisfy the requirement of “Were both plots created on the same set of axes?”

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter3: Assignment, Formatting, And Interactive Input
Section3.6: A Case Study: Acid Rain
Problem 7E
icon
Related questions
Question

Please edit my MATLAB coding to include/fix the missing lines of coding that will satisfy the requirement of “Were both plots created on the same set of axes?”

Function
1 function pressureTable isothermalIG(gas Names, molarMass, volumeStartStop, tempKelvin)
m= 100; % mass (grams)
R 8.31447; % ideal gas constant
V
den V'*molarMass ;
pressureTable m. *R. *tempKelvin./den; % total eqn
plot (V, pressure Table (:,1));
I hold on
3
4
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 end
linspace(volumeStartStop (1), volumeStartStop(2),50);
% denominator of eq
plot (V, pressureTable (:,2));
grid on
legend (gasNames);
xlabel('Volume');
ylabel('Pressure');
title('Pressure vs Volume');
Code to call your function >
1 gasNames ["oxygen", "carbon dioxide"];
2 molarMass [31.999, 44.01]; %grams/mol
3 volumeStart Stop [0.2 0.5]; %cubic meters
4 tempKelvin 350 %Kelvin
5 pressureTable isothermalIG(gasNames, molar Mass, volumeStartStop, tempKelvin);
Previous Assessment: 4 of 5 Tests Passed
> • Is first column in output matrix of pressure values correct? (Pretest)
>> Is second column in output matrix of pressure values correct? (Pretest)
→ Is output matrix of pressures correct for inputs different than those shown in the "Code to Call Your Function" example?
Does your function contain the MATLAB commands to generate the specified figure?
Were both plots created on the same set of axes?
Make sure you create two separate plots on the same axes using the PLOT command.
Do not overwrite earlier plots with later plots.
See the MATLAB documentation for futher information about creating multiple plots on the same axis.
Transcribed Image Text:Function 1 function pressureTable isothermalIG(gas Names, molarMass, volumeStartStop, tempKelvin) m= 100; % mass (grams) R 8.31447; % ideal gas constant V den V'*molarMass ; pressureTable m. *R. *tempKelvin./den; % total eqn plot (V, pressure Table (:,1)); I hold on 3 4 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 end linspace(volumeStartStop (1), volumeStartStop(2),50); % denominator of eq plot (V, pressureTable (:,2)); grid on legend (gasNames); xlabel('Volume'); ylabel('Pressure'); title('Pressure vs Volume'); Code to call your function > 1 gasNames ["oxygen", "carbon dioxide"]; 2 molarMass [31.999, 44.01]; %grams/mol 3 volumeStart Stop [0.2 0.5]; %cubic meters 4 tempKelvin 350 %Kelvin 5 pressureTable isothermalIG(gasNames, molar Mass, volumeStartStop, tempKelvin); Previous Assessment: 4 of 5 Tests Passed > • Is first column in output matrix of pressure values correct? (Pretest) >> Is second column in output matrix of pressure values correct? (Pretest) → Is output matrix of pressures correct for inputs different than those shown in the "Code to Call Your Function" example? Does your function contain the MATLAB commands to generate the specified figure? Were both plots created on the same set of axes? Make sure you create two separate plots on the same axes using the PLOT command. Do not overwrite earlier plots with later plots. See the MATLAB documentation for futher information about creating multiple plots on the same axis.
The pressure, volume, temperature, and mass of an ideal gas are related by the ideal gas equation of state:
mRT
M
PV =
where P represents pressure (Pascals), V represents volume (cubic meters), m represents mass (grams), T represents temperature (Kelvin), and M represents the molecular mass of the gas (grams/mole). R is the ideal
gas constant and has a value of 8.31447 Joules/(mole-Kelvin).
Write a function named isothermal IG that calculates the pressure behavior for the isothermal (constant temperature) expansion of two different ideal gasses from a starting volume to a final volume. Your function should
accept the following four inputs (in order):
▪ A string array containing the names of the two gases to be plotted.
■ A vector of the molecular masses of each gas.
▪ A two-element vector with the initial volume and the final volume for the expansion process as the first and second elements respectively.
▪ A scalar variable giving the temperature at which the process occurs.
Your function should use these inputs to calculate the pressures for a mass of 100 grams of each of the input gasses for 50 equally-spaced volumes between the minimum and maximum input volume values.
1. Output these results in a 50x2 matrix (one column for each gas) of pressure values with each row corresponding to one of the volume values.
2. Generate a figure with an overlay plot of pressure versus volume for both gases on a single set of axes.
3. Use MATLAB commands to add an appropriate title, axis labels, grid and legend to the figure. Use the text in the first input (the string array of gas names) in your legend.
Transcribed Image Text:The pressure, volume, temperature, and mass of an ideal gas are related by the ideal gas equation of state: mRT M PV = where P represents pressure (Pascals), V represents volume (cubic meters), m represents mass (grams), T represents temperature (Kelvin), and M represents the molecular mass of the gas (grams/mole). R is the ideal gas constant and has a value of 8.31447 Joules/(mole-Kelvin). Write a function named isothermal IG that calculates the pressure behavior for the isothermal (constant temperature) expansion of two different ideal gasses from a starting volume to a final volume. Your function should accept the following four inputs (in order): ▪ A string array containing the names of the two gases to be plotted. ■ A vector of the molecular masses of each gas. ▪ A two-element vector with the initial volume and the final volume for the expansion process as the first and second elements respectively. ▪ A scalar variable giving the temperature at which the process occurs. Your function should use these inputs to calculate the pressures for a mass of 100 grams of each of the input gasses for 50 equally-spaced volumes between the minimum and maximum input volume values. 1. Output these results in a 50x2 matrix (one column for each gas) of pressure values with each row corresponding to one of the volume values. 2. Generate a figure with an overlay plot of pressure versus volume for both gases on a single set of axes. 3. Use MATLAB commands to add an appropriate title, axis labels, grid and legend to the figure. Use the text in the first input (the string array of gas names) in your legend.
Expert Solution
steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Longest Common Subsequence
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr