Professional Documents
Culture Documents
Part B
Part B
Question 5
% Problem 5
% Solve for 'x' using fsolve to find the value of 'x' that satisfies the equation
SolutionX = fsolve(fun, 0); % Solving to find the value of 'x'
% Plot the equation and add 70 to it (to match the L=70 condition)
x_values = 0:0.01:0.6; % Define x values for the plot
plot(x_values, fun(x_values) + 70); % Plot L vs. x
grid on
title('L vs x') % Title of the graph
xlabel('x [mol B/mol]') % Label for the x-axis
ylabel('x [mol]') % Label for the y-axis
% Plot the equation and add 70 to it (to match the L=70 condition)
x_values = 0:0.01:0.6; % Define x values for the plot
y_values = fun(x_values) + 70; % Calculate corresponding y-values
Conclusions:
In this MATLAB code, a numerical solution is obtained for the equation
representing a chemical process. The code successfully finds the corresponding
x-value for a given y-value, allowing for the precise determination of the
chemical reaction's state under specific conditions.
Question 6
% Problem 6
x = linspace(0,1,100);
y = linspace(0,1,100);
surf(X,Y,Z);
xlabel('x');
ylabel('y');
zlabel('Temperature');
figure;
contour(X,Y,Z);
xlabel('x');
ylabel('y');
colorbar;
% Print results
fprintf('Work done in each segment: ');
disp(workDone);
fprintf('Total work done: %.2f\n', totalWork);
% Bar diagram
subplot(2, 1, 1);
bar(workDone);
title('Work Done in Each Segment');
xlabel('Segment');
ylabel('Work Done');
xticklabels({'1', '2', '3', '4', '5'});
% Pie diagram
subplot(2, 1, 2);
pie(workDone, {'Segment 1', 'Segment 2', 'Segment 3', 'Segment 4', 'Segment 5'});
Conclusions:
In this MATLAB code, data from 'P7.csv' was read and processed to calculate
the work done for each of the five path segments, with the results added as
the third row of the matrix 'M'. The total work done over the entire path was
computed, and visualizations in the form of bar and pie diagrams were created
to illustrate work distribution among segments. Additionally, the data was
structured into a table and saved as 'table.csv' for further analysis and
reference.
Question 8
clc;
clear all;
close all;
C = 40;
S = 30;
Conclusions:
The code provided calculates the values of R and L that minimize the total cost
of a fenced enclosure while ensuring a given area constraint A. It utilizes the
fminsearch optimization function with a resolution of 0.01 meters. The results
are then displayed, including the minimum length (L), the corresponding radius
(R), and the minimum cost.
Question 9
Part a)
syms r V A
Part b)
function A = computeA(R)
global V
Part C)
global V
V = 10; % Set the value of V
% Plot V versus r
figure;
plot(r_values, A_values);
xlabel('r (cm)');
ylabel('A');
title('Paper Cup Area vs. r');
grid on;
Conclusions:
In conclusion, we have successfully addressed the given tasks and questions
related to the conical paper cup problem. Here are the key findings:
a. We derived an expression for the paper surface area 'A' as a function of the
base radius 'r' and volume 'V' by eliminating the height 'h' from the equations.
b. We created a user-defined function that computes 'A' based on a given 'r'
and the global value of 'V'.
c. Using the 'fminbnd' function, we found the optimal 'r' that minimizes 'A' for
'V = 10 cm^3'. The corresponding 'h' was calculated as well. We also
investigated the sensitivity of the solution by plotting 'V' versus 'r' and
identified the range of 'r' values that cause 'A' to increase by 10% above its
minimum value.
The analysis and code implementation provided a comprehensive solution to
the conical paper cup problem, allowing us to determine the optimal
dimensions for minimizing the paper surface area while meeting the specified
volume constraint.
Question 10
Part a)
Part b)
% Define constants
k1 = 1e4;
k2 = 1.5e4;
d = 0.1;
Conclusion
In conclusion, the MATLAB function successfully computes the distance 'x' as a
function of weight 'W' and the given spring constants and displacement 'd',
providing a clear relationship between them. The resulting plot illustrates how
'x' varies with 'W' for the specified constants, offering valuable insights into the
behavior of the mass-spring system.