Just need a quick answer on whether this function and script make sense or if I need to make it more clear so that it is easier to understand
조회 수: 6 (최근 30일)
이전 댓글 표시
Im trying to write a function and script to determine the pressure in a sealed container with a volume of 5 gallons containing 25 moles of methane at a temperature of 155*C
This is the function that I wrote
function [P] = Pressure_Conversion(n, v, t)
% Determine the pressure given volume, temperature, and number of moles of
% methane
%
% Variables
%
% P = Pressure in atm
% n = Number of moles of methane
% r = Ideal Gas Constant
% v = Volume in Liters
% t = temperature in kelvin (*C+ 273.15)
%
% Calculations
%
r = 8.314; % L kPaK^-1
P = n*r*t/v; % atm
end
And this is the script I wrote
% Script for determining the pressure given the volume, temperature and
% number of moles of methane
%
% Inputs
%
n = input('Number of moles of Methane=');
v = input('Volume in Gallons=');
t= input('Temperature in Celcius=');
%
%Convert variables to correct units
%
v = v*3.785;
t = t+273.15;
%
%Call in Function
%
P = Pressure_Conversion(n, v, t);
%
%Print Function
%
fprintf('The pressure is %.3f atm\n',P)
댓글 수: 0
답변 (1개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Oil, Gas & Petrochemical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!