You are here

Solution to Exercise 4.1

9 October, 2015 - 15:01
% This script converts pressures from psi to kPa
% User is prompted to enter pressure in psi
clc                         % Clear screen
disp('This script converts pressures from psi to kPa:')
disp(' ')                   % Display blank line
psi=input('What is the pressure value in psi? ');
kPa=psi*6.894757;           % Calculating pressure in kPa
disp(' ')                   % Display blank line
str = ['The converted pressure is: ', num2str(kPa), ' kPa.'];
disp(str);

The script output is as follows:

This script converts pressures from psi to kPa:
    
What is the pressure value in psi? 150

The converted pressure is: 1034.2135 kPa.