Answer to Question #182889 in MatLAB for gara

Question #182889

For each of the following, write an algorithm and draw a flow chart then write a MATLAB code in separate script:

1. Finding the area of a rectangle and show it as below: The Area of This rectangle = ?

2. Finding sum of the even numbers from 2 to 100,

3. Finding the volume of a cylinder and show it as: The volume of This cylinder = ?

4. Finding the maximum number among three numbers entered by the user.


1
Expert's answer
2021-04-19T07:50:04-0400


1)


length = input('Enter the length of the rectangle: ');
  breadth = input('Enter the breadth of the rectangle: ');
  a = length*breadth;
  fprintf('Area = %.2f\n',a);


2)



Counter = 2
Sum = 0;
while Counter <= 1000
  Sum = Sum + Counter;     
  Counter = Counter + 2;   
end
disp(Sum)     


3)



L = 5;
r = 3;
h = [0:.2:r]';
V = ((r^2*acos((r-h)/r)) - (r-h).*sqrt(2*r*h - h.^2))*L;
plot(h,V)
title('Horizontal Cylinder Liquid Volume')
ylabel('Liquid Volume (in^3)')
xlabel('Liquid Depth (in)')


4)

    function [p] = MAX(g,h,j)
if g>h && g>j
    p=g;
elseif h>g && h>j
    p=h;
else
    p=j;
end

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS