PSLP File 1
PSLP File 1
Installation of SCILAB:
http://www.scilab.org/.
Making directory by name in the root folder and changing the current
directory .
2. Menu File
clc
m = input('number of rows: ');
n = input('number of columns: ');
a = zeros(m,n);
for i=1:m
for j=1:n
a(i,j)=input(sprintf('enter a(%d,%d): ',i,j));
end
num=input('Enter the Scalar Number: ');
res=a*num;
disp("REQUIRED OUTPUT :")
disp(res);
Result :
ii. Multiplication of a matrix with a matrix
clc
disp("Enter matrix 1");
m = input('number of rows: ');
n=
input('n
umber
of
columns
: ');
mat1 =
zeros(m
,n); for
i=1:m
for j=1:n
mat1(i,j)=input(sprintf('enter a(%d,%d): ',i,j));
end
end
disp("Enter matrix 2");
x = input('number of rows: ');
y = input('number of columns: ');
mat2 = zeros(x,y);
for i=1:x
for j=1:y
mat2(i,j)=input(sprintf('enter a(%d,%d): ',i,j));
end
end
res=mat1*mat2;
disp(res);
Result:
clc;
x=1:10;
y=x.*x;
plot(x,y);
xlabel("Natural number");
ylabel("Sqaure of number");
title("Square Plot");
Result :
Program – 2
Objective : Program for demonstration of Theoretical Probability Limit .
The demonstration is done by simulating the flipping of a coin. The objective is to show
that as the Number of flips increases, the theoretical probability limit of 0.5 is
approached. The practical Probability is simulated by the generation of the random
number for each flip as follows:
b. Round the Number obtained and consider x=random variable, and x=Numbers of Head
obtained in the experiment.
c. Repeat this experiment for the various iterations up to 1, 00,000 and keep storing the
result in an Array. Calculate the probability in each case.
d. Plot the graph between the Number of the throw and the Probability.
Result:
num_iterations = 100000;
probabilities = flip_coins(num_iterations);
x = 1:num_iterations;
plot(x, probabilities);
xlabel('Number of Flips');
ylabel('Probability of Heads');
title('Demonstration of Theoretical Probability Limit .');
Graph: