Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

WRITE IN MATLAB - 15 554 non lus) - tambro x M Textbook - tambroma13 XE ENGR - G

ID: 3209964 • Letter: W

Question

WRITE IN MATLAB

- 15 554 non lus) - tambro x M Textbook - tambroma13 XE ENGR - Google Drive x6 ENGR. - Google Drive x C Chegg Study | Guided Sox: ENGR1671-cha. 4-67 - x + C A Secure | https//drive.google.com/drive/folders/0B1DVpirgDRMCNVROQmI5OXZCRWC S-ax A o o 218 Chapter 6: Programming in MATLAB 31. Write a program in a script file that converts a measure of pressure given in units of eitha Pa, psi, atm, or torr to the equivalent quantity in different units specified by the user. The program asks the user to enter the amount of pressure, its current units, and the desired new units. The output is the spec- ification of pressure in the new units. Use the program to: (a) Convert 70 psi to Pa. (6) Convert 120 torr to atm. (c) Convert 8000 Pa to psi. 32. In a one-dimensional random walk, the positions of a waller is computed by: O e 9 ] Na os Pai Screenshot Added X ACCcreenshot 8C added to our Dropbox * * * ad 23/2/2018

Explanation / Answer

MATLAB code

close all
clear
clc

curr_P = input('Enter Pressure: ');

disp('Select The Current Unit:');
fprintf(' 1. Pa ');
fprintf(' 2. psi ');
fprintf(' 3. atm ');
fprintf(' 4. torr ');
curr_unit = input('Your Selection (1|2|3|4): ');

disp('Select The New Unit:');
new_unit = input('Your Selection (1|2|3|4): ');

% Matrix for conversion
% A(i,j) represents conversion from pressure (in i) to pressure (in j)
A = [1 6894.75 101325 133.3223684211;
0.0001450378911491 1 14.69596432068 0.01933679515879;
0.00000986923266716 0.0680458919319 1 0.001315789473684;
0.007500616827042 51.71487786825 760 1];
new_P = A(new_unit,curr_unit)*curr_P;
fprintf('New Pressure: %.15f ', new_P);

Example-1

Enter Pressure: 70

Select The Current Unit:

1. Pa

2. psi

3. atm

4. torr

Your Selection (1|2|3|4): 2

Select The New Unit:

Your Selection (1|2|3|4): 1

New Pressure: 482632.500000000000000

Example-2

Enter Pressure: 120

Select The Current Unit:

1. Pa

2. psi

3. atm

4. torr

Your Selection (1|2|3|4): 4

Select The New Unit:

Your Selection (1|2|3|4): 3

New Pressure: 0.157894736842080

Example-3

Enter Pressure: 8000

Select The Current Unit:

1. Pa

2. psi

3. atm

4. torr

Your Selection (1|2|3|4): 1

Select The New Unit:

Your Selection (1|2|3|4): 2

New Pressure: 1.160303129192800