Matlab Part
Matlab Part
Matlab Part
QUESTION NO.8
Calculate the molar volume and density of CO2 at 50 bar
and 450 K (176.85°C) using ideal gas law and the
Redlich-Kwong (RK) equation of state. Under these
conditions, the molar volume given in Perry’s Handbook
is 0.7065 m3 /kmol (p. 2-241, 8th ed.). Cubic form of the
Redlich-Kwong equation:
% Redlich-Kwong parameters
a = 0.42748 * (R^2 * Tc^2.5) / Pc;
b = 0.08664 * R * Tc / Pc;
% Display results
disp('Results:');
disp(['Ideal Gas Molar Volume (m^3/mol): ', num2str(V_ideal)]);
disp(['Ideal Gas Density (mol/m^3): ', num2str(rho_ideal)]);
disp(['RK Molar Volume (m^3/mol): ', num2str(V_RK)]);
disp(['RK Density (mol/m^3): ', num2str(rho_RK)]);
QUESTION NO.9
Solve the following ODE:
y(0) = 0.1, use step size of 0.1
a) Compare (calculate the percent error at each point) the results with
exact solution which is as follows:
b) Repeat the solution with step size of 0.05 and again compare your
results with exact solution by calculating percent error at each point.
c) Repeat the solution with step size of 0.025 and compare your results
with exact solution.
d) Solve the same problem using ode45 built in command.
Code:
clc
% Define the exact solution
exact_solution = @(t) (3*exp(30*t)/26 + 4*exp(30*t));
Results:
QUESTION NO.10
y=x4+3x2+2x+5 write a program to find its roots.
Code & Result:
% Define the coefficients of the polynomial y = x^4 + 3x^2 + 2x + 5
coefficients = [1 0 3 2 5];
QUESTION NO.11
Write a program to calculate x
QUESTION NO.12
. The x-y data of a system is given below. Plot the data and
properly label it withinx = 0 to x = 1.4. find area under curve
within this range as well.
Code & Result:
clc
% Given data
x = [0, 0.2, 0.4, 0.6, 0.8, 1.0, 1.2, 1.4, 1.6];
y = [5, 5.2, 5.3, 5.4, 5.5, 5.6, 5.7, 5.7, 5.8];
Graph:
QUESTION NO.13
A trigonometric identity is given by following relation:
Verify that the identity is correct by calculating the left and right
hand side of equations atx=pi.
QUESTION NO.14
Create following matrices in Matlab
Code:
% Given matrices
A = [5 2 4; 1 7 -3; 6 -10 0];
B = [11 5 -3; 0 -12 4; 2 6 1];
C = [7 14 1; 10 3 -2; 8 -5 9];
% b. Calculate A + (B + C) and (A + B) + C
sumBplusC = B + C;
sumAplusBplusC = A + sumBplusC;
sumAplusB = A + B;
sumAplusBplusC2 = sumAplusB + C;
Result: