Assignment
Assignment
1
QUESTION 2.............................................................................................................................................1
QUESTION 3.............................................................................................................................................1
QUESTION 4.............................................................................................................................................2
QUESTION 5.............................................................................................................................................2
QUESTION 6.............................................................................................................................................2
QUESTION 7.............................................................................................................................................2
QUESTION 8.............................................................................................................................................2
QUESTION 9.............................................................................................................................................2
QUESTION 7.6..........................................................................................................................................2
QUESTION 7.13........................................................................................................................................2
QUESTION 1
volume of a right circular cylinder
clc
r = input('Enter value for r: '); % input the value for radius
h = input('Enter value for h: '); % input the value for height
v = pi * r .^2 .* h; % Computing the value of volume
fprintf('The value for volume is: %f \n\n',v) % output value for volume
QUESTION 2
creating vector h
clear all
a = input('Enter the first value a: '); % input the value of a
b = input('Enter the second value b: '); % input the value of b
c = input('Enter the spacing value c: '); % input the spacing value c
h=[a:c:b] % creating vector h
QUESTION 3
%volume of a right circular cylinder
clear all
QUESTION 4
disp('----Conversion of inches to feet---') %showing title of the table
QUESTION 5
fprintf('%6s %12s\n','inch','feet'); % column headings of the table
QUESTION 6
inch=[0:10:120]; %creating inches vector
QUESTION 7
feet=inch/12; %calculating corresponding feet value
QUESTION 8
conversion=[inch; feet]; % grouping inch and feet in 2 column matrix
QUESTION 9
fprintf('%6.2f %12.8f \n',conversion); % sending table to command window
%---------------------------------------------------------------------------
QUESTION 7.6
clear all
age=input('\n Enter your age:');
X = ['Your age is ', num2str(age),];
disp(X)
QUESTION 7.13
% PART a
a=input('\n\n Enter the spacing value: '); % spacing value
disp('--Conversion of Farenheit to Kelvin--') %showing title of the table
disp('Farenheit Kelvin') % column headings of the table
Farenheit=(0:a:200); %creating Farenheit vector
T=Farenheit + 459.67;
Kelvin=(5.*T)./9; %calculating corresponding Kelvin value
conversion=[Farenheit; Kelvin]; % grouping inch and feet in 2 column matrix
fprintf(' %d %12.8f\n',conversion); % sending table to command window
% PART b
clear all
a=input('\n Enter the spacing value: '); % spacing value
t_start = input('Enter the starting temperature: '); %start temperature
d = input('Enter the number of lines: '); %number of line of the table
disp('--Conversion of Celsius to Rankine--') %showing title of the table
disp('Celsius Rankine') % column headings of the table
Celsius=(t_start:a:d*a); %creating Celsius vector
T=(9.*Celsius)./5;
Farenheit=T+32; %calculating corresponding Farenheit value
conversion=[Celsius; Farenheit]; % grouping Celsius and Farenheit in 2 column matrix
% PART c
clear all
a=input('\n Enter the spacing value: '); % spacing value
t_start = input('Enter the starting temperature: ');
disp('--Conversion of Celsius to Farenheit--') %showing title of the table
disp('Celsius Rankine') % column headings of the table
Celsius=(t_start:a:25*a); %creating Celsius vector
T=(9.*Celsius)/5;
Rankine=T+491.67; %calculating corresponding Kelvin value
conversion=[Celsius; Rankine]; % grouping inch and feet in 2 column matrix