MATLAB Engineers use both English and SI (Systeme International d’Unites) units
ID: 3840248 • Letter: M
Question
MATLAB
Engineers use both English and SI (Systeme International d’Unites) units on a regular basis. Some fields use primarily one or the other, but many combine the two systems. For example, the rate of energy input to a steam power plant from burning fossil fuels is usually measured in Btu/hour. However, the electricity produced by the same plant is usually measured in joules/s (watts). Automobile engines, by contrast, are often rated in horsepower or in ft lbf/s. Here are some conversion factors relating these different power measurements: 1 kW = 342.14 Btu/h = 737.56 ft lbf/s 1 hp = 550 ft lbf/s = 2544.5 Btu/h 1-Ask user to enter the minimum and maximum kilowatt values. In nested for loops, get one random number at a time between the minimum and maximum kilowatt values and save it into the 4x3 matrix using indexing. p.334 Convert kw to btu/h, hp, and ft lbf/s. You now have four 4x3 matrices. Print a conversion table as shown below for kw to btu/h, hp, and ft lbf/s without using a loop. 2-Find the kilowatt values in the matrix that are within a standard deviation on either side of the overall kilowatt average in the 4x3 matrix. Use find not a loop or if. Print a conversion table as shown below for kw to btu/h, hp, and ft lbf/s for kilowatt values from the between kilowatt average ± standard deviation using the result of the find without using a loop.Above is what we are supposed to get for as output
Output: Enter the minimum kW: 15 Enter the maximum kW: 120 Blank line Power Conversion Table Center title over columns Blank line Btu/hr hP ft lbf/s kW Column headers over numbers 100.5 343077.0 134.8 74158.7 110.9 378421.6 148.7 81798.7 44.2 150961.0 59.3 32631.4 USE fprintf FOR ALL OUTPUT. 116. 396877.3 156.0 85788.0 110.1 375704.4 147.7 81211.4 81.4 277740.4 109.2 60035.7 Each 4 x 3 matrix printed as a column, p.124 72.4 247115.9 97.1 53416.0 Adjust the field widths so numbers right aligned, 31.5 107 (650.9 42.3 23269.6 p.3 Ch07 fprintf input jh.pdf on Canvas 28.3 96678.3 38.0 20897.7 one decimal place 25.2 86128.4 33.8 18617.3 115.5 394232.6 154.9 85216.4 116.9 398920.9 156.8 86229.8 Blank line Power conversion of kW between average+/-standard deviation Btu/hr hP ft lbf/s kW Column headers over numbers 100.5 343077.0 134.8 74158. Numbers right aligned with one decimal place 110.9 378421.6 148 81798.7 44.2 150961.0 59.3 32631.4 116. 396877.3 156.0 85788.0 110.1 375704.4 147.7 81211.4 81.4 277740.4 109.2 60035.7 72.4 247115.9 97.1 53416.0 115.5 394232.6 154.9 85216.4 116.9 398920.9 156.8 86229.8Explanation / Answer
Matlab code
clc;clear;% Clearing the command window and workspace
minKW = input('Enter the minimum kW: '); % getting min KW
maxKW = input('Enter the maximum kW: '); %getting Max KW
fprintf(' Power Conversion Table '); % Printing the heading
for i = 1:4 % nested loop to generate random numbers b/w Min KW and Max KW
for j = 1:3
M1(i,j) = (maxKW-minKW)*rand+minKW;% Generating random KW
end
end
M2 = M1*342.14; % Computing in btu/hr
M3 = M1*1.3410; % Converting to hP
M4 = M1*737.56; % Converting to ft lbf/s
I = 1:12; % Index
fprintf('%6s %11s %8s %11s ','kW','But/hr','hp','ft lbf/s'); % Heading
fprintf('%7.1f%12.1f%9.1f%10.1f ',[M1(I);M2(I);M3(I);M4(I)]); % Printing the result
fprintf(' Power Conversion of kW between average+/-standard deviation ');
avg = mean(M1(I)); % Aeverage
dev = std(M1(I)); % Standard deviation
I = find(M1 > (avg-dev) & M1 < (avg+dev)); % Index of KW within +/-std
fprintf('%6s %11s %8s %11s ','kW','But/hr','hp','ft lbf/s');
fprintf('%7.1f%12.1f%9.1f%10.1f ',[M1(I');M2(I');M3(I');M4(I')]); % printing the numbers with Index I
OUTPUT
Enter the minimum kW: 15
Enter the maximum kW: 120
Power Conversion Table
kW But/hr hp ft lbf/s
24.0 8204.2 32.2 17686.1
18.1 6181.8 24.2 13326.3
66.3 22685.2 88.9 48903.1
63.2 21616.1 84.7 46598.4
42.6 14561.7 57.1 31391.0
112.5 38500.9 150.9 82997.4
75.7 25915.4 101.6 55866.6
116.1 39730.8 155.7 85648.6
99.1 33908.3 132.9 73097.0
91.7 31369.0 122.9 67623.0
39.9 13656.4 53.5 29439.5
72.4 24775.9 97.1 53410.1
Power Conversion of kW between average+/-standard deviation
kW But/hr hp ft lbf/s
66.3 22685.2 88.9 48903.1
63.2 21616.1 84.7 46598.4
42.6 14561.7 57.1 31391.0
75.7 25915.4 101.6 55866.6
99.1 33908.3 132.9 73097.0
91.7 31369.0 122.9 67623.0
39.9 13656.4 53.5 29439.5
72.4 24775.9 97.1 53410.1
>>
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.