Answer No 2:: % Taking User Input
Answer No 2:: % Taking User Input
clear all
clc
% Taking user input
prompt = 'Specify L/B ratio :'
LB = input(prompt);
prompt = 'Specify L/T ratio :'
LT = input(prompt);
L=input('Enter the length of vessel:');
if (L>0)
B=L/LB;
T=L/LT;
syms x
y=(B/2)*(1-(2*x/L)^2)*(1-(2*T/T)^2);
Waterplane_area=int(y,0,L);
display("The Waterplane area for this length is");
display(Waterplane_area);
else
display("Length must always be a positive value");
end
Command Window:
>>
Output:
1 x
Calculate the value of r ds , ds for the rectangle 2, 2 (1,1) where
S S
r3
P ( x, y, z ) (6,5,10)
Answer:
clear all
clc
% Taking user input
prompt = 'The farthest vertex of the rectangle [x y]:'
x3 = input(prompt);
prompt = 'Specify any point outside the rectangle [x y z]'
q = input(prompt);
x1 = [-2 -2];
x2 = [x3(1) -2];
x4 = [-2 x3(2)];
% Displaying the rectangle
rectangle('Position',[-2 -2 3 3]);
X = -2:1:x3(1);
Y = -2:1:x3(2);
display(X);
display(Y);
Output:
X = 1×4
-2 -1 0 1
Y = 1×4
-2 -1 0 1
I = 0.0710
W = 0.0027