%% Holly Moore % Matlab for Engineers, Third Edition % Chapter 7 Homework Solutions clear,clc, close all %% Problem 7.1 x = input('Enter a value of x: ') result = sin(x) %% Problem 7.3 area = input('Enter the area of the base of a cone ') h = input('Enter the height of a cone ') volume = 1/3*area*h %% Problem 7.5 first_name = input('Enter your first name, inside single quotes ') last_name = input('Enter your last name, inside single quotes ') disp(['Your name is: ',first_name,' ',last_name]) %or first_name=input('Enter your first name ','s'); last_name = input('Enter your last name ','s'); disp(['Your name is: ', first_name,' ',last_name]) %% Problem 7.7 x = input('Enter an array of numbers ') num = length(x); disp(['You entered ',num2str(num),' numbers']) %% Problem 7.9 num = 1:6; mult = num*6; table =[num;mult]; fprintf('%5.0f times 6 is %3.0f \n',table) %% Problem 7.11 inches = 1:10; angstroms = inches*2.54*10^8; disp('Inches Are to big to measure in Angstroms') disp('Inches Angstroms') fprintf('%5.0f %7.2e \n',[inches;angstroms]) %% Problem 7.13 start = 0; stop = 200; incr = input('Enter the temperature increment '); F=start:incr:stop; K = (F+459.6)*5/9; disp('Temperature Conversions') disp(' F K') fprintf('%5.0f %8.2f \n', [F;K]) %b start = input('Enter the starting temperature '); incr = input('Enter the increment '); stop = start +incr*24; C = start:incr:stop; R = (C + 273)*9/5; disp('Temperature Conversion') disp(' C R') fprintf('%5.0f %8.2f \n',[C;R]) %c start = input('Enter the starting temperature ') incr = input('Enter the increment ') num = input('Enter the number of lines ') stop = start + incr*(num-1); C = start:incr:stop; F = 9/5*C + 32; disp('Temperature Conversion') disp(' C F') fprintf('%5.0f %8.2f \n',[C;F])