You are on page 1of 3

Task1:

A=S(s-a)(s-b)s-c)^1/2
Where s=a+b+c/3
Write matlab function that will accept a,b,c as
input and return the value of A?

program:-
function[A]=Arsalan(a,b,c)
%this function returns the area A and a,b & c
.the formula for area calculation
s=(a+b+c)/2;
A=sqrt(s*(s-a)*(s-b)*(s-c));

Task2:-
Write a function m-file that takes input from
user and return 1 if all values are +ve,-ve if
All values are negative,0 otherwise.

program:-
x=input('enter the value g');
if (x>0)
disp('1')
elseif (x<0)
disp('-1')
else
disp('0')
end

Task3:-
If y=sinx/x,v+1/(x-1)^2=x,v=x^2+1/x^2-4
W=(10-x)^1/3-2/a-x^2)1/2

program:-
%plot1
x=1:0.001:10;
a=sin(x)
b=x
y=a/b
subplot(2,2,1)
plot(x,y)
%plot2
x=1:10;
s=(x-1).^2
a=1./s
u=a+x
subplot(2,2,2)
plot(x,u)
%plot3
x=1:10;
a=x.^2
d=a+1
s=a-4
w=d./s
subplot(2,2,3)
plot(x,w)
%plot4
x=1:10;
a=(10-x).^(1./3)
den=(4-x.^2).^(1./2)
s=a-2
z=s./den
subplot(2,2,4)
plot(x,z)

Task#4:-
Find the first integers `n` for which
1+2+3+…………..n is greater then 1000

program:-
n=1;
while(sum(1:n)<1000)
n=n+1;
end

Task #5:-
function[f]=Arsalan(n)
f(1)=1
f(2)=2
for k=3:n
f(k)=f(k-1)+f(k-2)
end

You might also like