Question

In: Computer Science

MATLAB language; ... Boyle's law of gases says that: P1V1 = P2V2 Make a program (script)...

MATLAB language;

...

Boyle's law of gases says that:

P1V1 = P2V2

Make a program (script) that calculates any of the 4 parameters, based on the elements that the user decides, that is:

P1 = P2V2 / V1 - ask for the data that is needed. P2, V2, V1

V1 = P2V2 / P1 - ask for the data that is needed. P2, V2, P1

P2 = P1V1 / V2 - ask for the data that is needed. P1, V2, V1

V2 = P1V1 / P2 - ask for the data that is needed. P1, P2, V1

REMEMBER THAT FROM THAT ELECTION, THE REQUIRED VALUES ARE ASKED

Solutions

Expert Solution

%{
MATLAB script to calculate the desired parameter value out of four (P1, V2, P2, V2)
based on the values entered for other parameters
%}

fprintf("Enter parameter values below and leave the unknown parameter blank to calculate its value.\n");

P1 = input("Enter value of P1: ");
P2 = input("Enter value of P2: ");
V1 = input("Enter value of V1: ");
V2 = input("Enter value of V2: ");

if(isempty(P1))
if( isempty(P2) || isempty(V1) || isempty(V2) )
fprintf("Enter atleast any 3 parameters to calculate value of remaining one\n");
else
P1 = P2 * V2 / V1;
fprintf("P1 = %f\n",P1);
end
elseif( isempty(P2) )
if( isempty(P1) || isempty(V1) || isempty(V2) )
fprintf("Enter atleast any 3 parameters to calculate value of remaining one\n");
else
P2 = P1 * V1 / V2;
fprintf("P2 = %f\n",P2);
end
elseif( isempty(V1) )
if( isempty(P1) || isempty(P2) || isempty(V2) )
fprintf("Enter atleast any 3 parameters to calculate value of remaining one\n");
else
V1 = P2 * V2 / P1;
fprintf("V1 = %f\n",V1);
end
elseif( isempty(V2) )
if( isempty(P1) || isempty(P2) || isempty(V1) )
fprintf("Enter atleast any 3 parameters to calculate value of remaining one\n");
else
V2 = P1 * V1 / P2;
fprintf("V2 = %f\n",V2);
end
else
fprintf("Enter any 3 parameters to calculate the value of 4th one.\n");
end


Related Solutions

Apply the Kinetic Theory of gases to explain Boyle's law, Charles' law and Dalton's law ?
Apply the Kinetic Theory of gases to explain Boyle's law, Charles' law and Dalton's law ?
In MATLAB: (a) Insert a comment in your script that says Problem 1: (b) Below this...
In MATLAB: (a) Insert a comment in your script that says Problem 1: (b) Below this comment, generate a vector of values called x that starts at −10, ends at 8, and has a step size of 0.1 between points. (c) Define the function f(x) = (x − 6)(x 2 − 1)(x + 8) in your script, then plot f(x) against x. (d) Plot the x- and y-axes on the plot in part (c). Mark each of the x-intercepts on...
MATLAB: Write as a script in the editor window of matlab. Quadratic roots. Write a program,...
MATLAB: Write as a script in the editor window of matlab. Quadratic roots. Write a program, quadroots.m, for finding the roots of the second- order polynomial ax2 + bx + c. Use the quadratic equation. The inputs are the coefficients a,b, and c and the outputs are z1 and z2. The program should produce (exactly) the following output in the Command window when run with (a, b, c) = (1, 2, −3):
MATLAB is program Respond fast please a quiz Create a MATLAB script. Using nested for loops,...
MATLAB is program Respond fast please a quiz Create a MATLAB script. Using nested for loops, evaluate the multivariable function: z = sin ⁡ ( x ) cos ⁡ ( y ) for x between -4 and 4 in steps of 1 y between -2 and 2 in steps of 1 Display the matrix z Cut and paste the following into a word doc and submit to this question. Your script code Your input Your output
MATLAB Write a script which asks the user of the program to provide an initial horizontal...
MATLAB Write a script which asks the user of the program to provide an initial horizontal position, initial vertical position, initial velocity, and angle. Create a time vector spanning from zero seconds to 100 seconds incremented at 0.01 seconds. Call the function that you created in the previous problem to calculate the trajectory and velocities of the projectile. Find the maximum height of the projectile and the time at which it reaches that point. Write a neat sentence stating what...
Language: matlab It is desired to create a mortgage estimator by writing a program containing a...
Language: matlab It is desired to create a mortgage estimator by writing a program containing a function. The user inputs the amount of loan (L), the loan term in number of months (N), and the annual interest rate (I) in the script. The script then makes use of a function that accepts these values as inputs through its argument and calculates and returns the monthly payment and the total payments over the life of the loan. The monthly payment and...
Develop a matlab script file to calculate the practical single phase transformer parameters. The program should...
Develop a matlab script file to calculate the practical single phase transformer parameters. The program should ask the user to provide the following individually: S_rated V1_rated V2_rated With secondary shorted P1 V1 With primary open P2 I2 The program should calculate Req Xeq Zeq Gc Ym Bm Make sure your code will pronmpt a message like: “Enter the real power at the primary winding when the secondary winding is shorted, P1=). Do the same for all parameters S, V1_rated, V2_rated,...
Use the postulates of the kinetic moleclar theory (KMT) to explain why boyle's law, charles's law,...
Use the postulates of the kinetic moleclar theory (KMT) to explain why boyle's law, charles's law, avogadro's law, and dalton's law of partial pressures hold true for ideal gases. Use the KMT to explain the P versus n (at constant V and T) relationship and the P versus T (at constant V and n) relationship.
how do i do standard deviation for boyle's law lab
how do i do standard deviation for boyle's law lab
Boyle's Law states that when a sample of gas is compressed at a constant temperature, the...
Boyle's Law states that when a sample of gas is compressed at a constant temperature, the pressure P and volume V satisfy the equation PV = C, where C is a constant. Suppose that at a certain instant the volume is 900 cm3 , the pressure is 160 kPa, and the pressure is increasing at a rate of 40 kPa/min. At what rate is the volume decreasing at this instant? --- Step 1: Write all the rates in the problem...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT