Escolar Documentos
Profissional Documentos
Cultura Documentos
Given two sides a=3.2 and b=4.6 of a triangle and angle =60 between a and b . find the length of third
side and area of triangle.
SOLUTION
a=3.2;
b=4.6;
c=sqrt(a^2+b^2-(2*a*b*1/2))
c =4.0841
QUESTION2
Write the programme to convert temp given in degree Celsius to Fahrenheit say 35.4C
SOLUTION
c=35.4
f=(c*9/5)+32
f =
95.7200
QUESTION3
𝑥2 𝑥4 𝑥6 𝑥8
𝑠 =1− + − +
2! 4! 6! 8!
SOLUTION
x=1.5;
s=1-(x^2/factorial(2))+(x^4/factorial(4))-
(x^6/factorial(6))+(x^8/factorial(8))
s =
0.0708
QUESTION
Write a script to prompt the user to enter a numeric value .Again prompt the user about the sign of the
number.
SOLUTION
EDITOR WINDOW
COMMAND WINDOW
QUESTION
Write the script to prompt the user to enter a numeric value and prompt the user if it is a positive value
SOLUTION
EDITOR WINDOW
COMMAND WINDOW
QUESTION
Function to take value and create a vector using colon operator with the two values (usinf only if
statement)
SOLUTION
EDITOR WINDOW
function vector=values(x1,x2)
vector=(x1:x2);
COMMAND WINDOW
values(2,5)
ans =
2 3 4 5
QUESTION
Prompt the user for a number to calculate its squae . if the number is negative ,convert it into positive
value and then calculate its square
SOLUTION
EDITOR WINDOW
COMMAND WINDOW
QUESTION
𝑦 = 2𝑥 2 + 1 for x<5
Otherwise 𝑦 = 3𝑥
SOLUTION
EDITOR WINDOW
QUESTION
*****
*****
*****
*****
SOLUTION
EDITOR WINDOW
for i=1:4;
for j=1:5;
fprintf('*')
end;
fprintf('\n')
end
COMMAND WINDOW
*****
*****
*****
*****
QUESTION
Write a program to illustrate the use of error statement.When a error is ncounterd during the addition
of two row vector.check the programe for th following data
EDITOR WINDOW
QUESTION
SOLUTION
EDITOR WINDOW
a=[0 10];
x=exp(-a);
y=a.^2;
semilogx(x,y)
title('plot x verus y'),xlabel('x axis'),ylabel('y axis')
grid on
GRAPH
plot x verus y
100
90
80
70
60
y axis
50
40
30
20
10
0
-5 -4 -3 -2 -1 0
10 10 10 10 10 10
x axis
QUESTION
Plot power v/s time for 0<t<8sec, with power on the logscale and time in the linear scale for a motor
whose performance equation are given as
ii)Torque 𝑡 = 8𝑒 −0.15𝑡
iii)power p=wt