Matlab03

.docx

School

Lamar University *

*We aren’t endorsed by this school

Course

MISC

Subject

Mechanical Engineering

Date

Apr 3, 2024

Type

docx

Pages

2

Uploaded by MinisterCheetah6009

Name: Phengang Heng Homework Matlab 03 % Part 1: Convert PSI to Pascal function pressure_Pa = psiToPascal(pressure_psi) % Conversion constants psi_to_Pa = 6894.76; % 1 psi = 6894.76 Pa % Convert pressure from PSI to Pascal pressure_Pa = pressure_psi * psi_to_Pa; end % Part 2: Calculate gas properties function [moles_kmol, pressures_Pa] = calculateGasProperties(molar_mass_kg_kmol, temperature_K, mass_kg, container_volume_m3) % Universal gas constant (Pa·m3/(K·kmol)) R = 8.3145e3; % Calculate the number of moles (in kmol) for each gas moles_kmol = mass_kg ./ (molar_mass_kg_kmol * 1e-3); % Calculate the pressure for each container (in Pa) pressures_Pa = (moles_kmol * R * temperature_K) / container_volume_m3; end % Test Part 1 pressure1 = psiToPascal(2960); % Space Shuttle Engine Pressure pressure2 = psiToPascal(195); % Internal Combustion Engine Combustion Chamber Pressure disp( 'Part 1 - Pressure Conversion:' ); disp([ 'Pressure 1 (Pa): ' num2str(pressure1)]); disp([ 'Pressure 2 (Pa): ' num2str(pressure2)]); % Test Part 2 molar_mass_kg_kmol = [28.966 31.999 4.020 28.0134 44.097]; temperature_K = 297; % Room temperature (K) mass_kg = 0.4; % 400 grams of each gas container_volume_m3 = 0.018; % Container volume (m3) [moles, pressures] = calculateGasProperties(molar_mass_kg_kmol, temperature_K, mass_kg, container_volume_m3); disp( 'Part 2 - Gas Properties:' ); disp( 'Number of moles of each gas (kmol):' ); disp(moles); disp( 'Pressure of each container (Pa):' ); disp(pressures); psiToPascal Error: File: psiToPascal.m Line: 26 Column: 1 This statement is not inside any function.
(It follows the END that terminates the definition of the function "calculateGasProperties".)
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help