So I have been assigned with this problem but I haven't been taught anything about MATLAB.I would be grateful if anyone is willing to help me with this.

2 views (last 30 days)
Problem Statement
Honey bees use caves, rock cavities and hollow trees as natural nesting sites. A beehive is an
enclosed structure in which some honey bee species live and raise their young. In a beehive,
every cell is a regular hexagonal prism, open at one end with a trihedral angle at the other
end. It is believed that bees form their cells in such away as to minimize the surface area for a
given volume, so in this way least amount of wax is used in cell constructions. Amazingly,
the apex angle θ is consistent in each of there cells. Based on the geometry of the cells, it can
be shown that the surface area is given by
S=6*s*h-3/2*s*s*Cot(theta)+(3*s*s*((3)^1/2/2)*csctheta
Where s, the length of the sides of the hexagon, and h, the height, are constants.
You have to use MATLAB to write a program which will provide optimal angle that the bees
should be prefer to minimize the surface area. Also use MATLAB code that determine the
minimum surface area of the cell (in terms of s and h).
Furthermore, if the height h is one unit while length s of the side of hexagon is 2√2 . what surface
area we get?
Program requirements
1. On (every) first run, the program must display name of your software house, and your
programming team along with student ids.
2. At this stage, a message should be displayed to press any key to continue.
3. The program should ask the user to input the angle, or the height h and side length s.
4. The program should apply the optimization technique learnt in class to find the solution.
Relevant MATLAB commands should be used to find derivative and solution of the
problem.
5. The optimal angle should be displayed as output. Also, the surface area should be
shown as output in term of h and s. Furthermore, the surface area corresponds to
height h equal to one and length of the side s of hexagon equal to 2√2 should be
presented as output.
6. At this stage, the program must ask the user if they wish to run another query or
terminate the program. Based on user input, program must act accordingly.

Answers (2)

Image Analyst
Image Analyst on 4 Dec 2022
Of course we can't just do the entire homework problem for you so the answer is you need to learn how to program in MATLAB yourself.
To learn many fundamental concepts, invest 2 hours of your time here:
If you have any questions ask your instructor or read the link below to get started:
Obviously we can't give you the full solution because you're not allowed to turn in our code as your own.

Razzaq
Razzaq on 13 Jan 2023
Edited: Image Analyst on 13 Jan 2023
Here is the complete code for your question:
% Display information about software house and programming team
disp('Software House: XYZ');
disp('Programming Team: Abdul Razzaq (12345), Abduls (67890)');
% Ask user to press any key to continue
input('Press any key to continue...');
% Ask user to input angle
% assuming angle = 60
angle = input('Input angle (in degrees): ');
% Validate user input
if angle < 0 || angle > 180
error('Invalid input: angle must be between 0 and 180 degrees');
end
% Convert angle from degrees to radians
angle = deg2rad(angle);
% Define the surface area function
S = @(x) 3*x(1)*x(2) + 3*x(1)^2*cot(angle) + 3*x(1)^2*csc(angle);
% Ask user to input initial s and h
% assuming s_init = 3, h_init = 2
s_init = input('Input initial s value: ');
h_init = input('Input initial h value: ');
% Find the minimum surface area
x0 = [s_init, h_init];
[s_opt, h_opt] = fminsearch(S, x0);
% Display the optimal angle and surface area
disp(['Optimal angle: ' num2str(rad2deg(angle)) ' degrees']);
disp(['Minimum surface area: ' num2str(S([s_opt, h_opt]))]);
% Find the surface area when h = 1 and s = 2*sqrt(2)
h = 1;
s = 2*sqrt(2);
disp(['Surface area when h = 1 and s = 2*sqrt(2): ' num2str(S([s, h]))]);
% Ask user if they wish to run another query or terminate the program
response = input('Run another query? (y/n)', 's');
if response == 'y'
% Run the program again
main();
else
% Terminate the program
return;
end

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!