Professional Documents
Culture Documents
C 15MAT Prgms
C 15MAT Prgms
Practice Programs
2.Program Compute area and circumference of a circle
clc
disp('Enter the radius r')
r=5
disp('Area of the Circle is =')
Area = pi*r^2
Circum = 2*pi*r
while(n>1)
fact = fact*n;
n=n-1;
end
fprintf('factorial is = %d\n', fact)
C = mean(A,2)
disp('Mean value of C')
D = mean(C)
Graded Exercise
1.Program to manipulate matrix
A = [1 2 3;4 5 6;7 8 9]
B = [3 3 3;3 3 3;3 3 3]
C = A + B
D = A - B
E = A * B
F = A.* B
G = A / 2
H = A ./ B
subplot(323)
plot(t,y2,'r')
title('coswave function y1')
xlabel('Time,Sec')
ylabel('Amplitude')
grid on
subplot(324)
y2_freqdomain = fft(y2);
stem(abs(y2_freqdomain),'r');
xlabel('Samples')
ylabel('Amplitude')
title('coswave in freqcy domain')
grid on
subplot(325)
plot(t,z,'g')
title('sum of Sin & cos function z')
xlabel('Time,Sec')
ylabel('Amplitude')
grid on
subplot(326)
z_freqdomain = fft(z);
stem(abs(z_freqdomain),'g');
xlabel('Samples')
ylabel('Amplitude')
title('Sum wave in freqcy domain')
grid on
syms x
z = sin(2*x);
f1 = diff(z);
subplot(312)
ezplot(f1)
f2 = int(z);
subplot(313)
ezplot(f2)
title('Graph for int of y = sin(x)')
xlabel('Time in sec')
ylabel('Amp in volts')
grid on
clc
clear all
syms x
f = x^2
g = 2*x
y1 = int(f)
y2 = int(g)
disp('Sum of integrals is = ')
y = y1 + y2
disp('Integration of sum 0f functions is = ')
z = int(f + g)
if(y==z)
disp('Hence integration of sum = sum of integrals')
else
disp('False')
end
%Median calculation
B = sort(A,'descend')
disp('median by cal and build_in fn is = ')
median_cal = B(round(len/2))
median_fn = median(A)
%Standard deviation
c = 0;
for i = 1:1:(len)
c = c + (A(i)-avg_fn)^2;
end
disp('Std deviation by cal and build_in fn is = ')
std_cal = sqrt(c/(len-1))
std_fn = std(A)
%Variance calculation
disp('variance by cal and build in fn is = ')
variance_cal = std_fn ^ 2
variance_fn = var(A)
if disc ==0
fprintf('The equation has a root\n')
r = -b/(2*a)
else
fprintf('The equation has no real roots\n')
end
end