Access over 35 million academic & study documents

Report

Content type
User Generated
Subject
Computer Science
School
Saudi electronic university
Type
Homework
Rating
Showing Page:
1/3
1. The area and circumference for a circle of any radius can be obtained by using the
following function:
Code:
function [area, circum] = circle_(radius)
area = pi*radius^2;
circum = 2*pi/radius;
end
Example: The area and circumference for a circle with radius 10 is
>> [A,C] = circle_(10)
A =
314.1593
C =
0.6283
2. The MATLAB code to plot a an ellipse of given horizontal radius, vertical radius, and its
center is shown below:
Code:
function ploty = draw_ellipse(a,b,x0,y0)
% a = horizontal radius
% b = vertical radius
% x0, y0 are the center of coordinates
t=-pi:0.01:pi;
x=x0+a*cos(t);
y=y0+b*sin(t);
ploty = plot(x,y,'r','Linewidth',2);
grid on
xlabel('x-axis')
ylabel('y-axis')
end

Sign up to view the full document!

lock_open Sign Up
Showing Page:
2/3
Example: An ellipse of horizontal radius 10, vertical radius 4 and center (6,7) is shown:
outp = draw_ellipse(10,4,6,7)
3. The MATLAB code is written to draw a convex hull, with the given 3-D points. Also the
volume is calculated.
Codes:
[x,y,z] = meshgrid(-2:1:2,-2:1:2,-2:1:2); % Set
of 3-D points
x = x(:);
y = y(:);
z = z(:);
% k1 is the convex hull
% volu is the voluem of the convex hall
[k1, volu] = convhull(x,y,z);
trisurf(k1,x,y,z,'FaceColor','red')
axis equal
Result:
The volume of the convex hull is 64

Sign up to view the full document!

lock_open Sign Up
Showing Page:
3/3

Sign up to view the full document!

lock_open Sign Up
Unformatted Attachment Preview
1. The area and circumference for a circle of any radius can be obtained by using the following function: Code: function [area, circum] = circle_(radius) area = pi*radius^2; circum = 2*pi/radius; end Example: The area and circumference for a circle with radius 10 is >> [A,C] = circle_(10) A = 314.1593 C = 0.6283 2. The MATLAB code to plot a an ellipse of given horizontal radius, vertical radius, and its center is shown below: Code: function ploty = draw_ellipse(a,b,x0,y0) % a = horizontal radius % b = vertical radius % x0, y0 are the center of coordinates t=-pi:0.01:pi; x=x0+a*cos(t); y=y0+b*sin(t); ploty = plot(x,y,'r','Linewidth',2); grid on xlabel('x-axis') ylabel('y-axis') end Example: An ellipse of horizontal radius 10, vertical radius 4 and center (6,7) is shown: outp = draw_ellipse(10,4,6,7) 3. The MATLAB code is written to draw a convex hull, with the given 3-D points. Al ...
Purchase document to see full attachment
User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.

Anonymous
Excellent resource! Really helped me get the gist of things.

Studypool
4.7
Indeed
4.5
Sitejabber
4.4