MATLAB Program for Uniform distribution

Program Code
%Uniform Distribution
clc;
close all;
clear all;
n=input('Input the end value of x = ');
a=input('Input the starting value of uniform distribution, a=');
b=input('Input the ending value of uniform distribution, b= ');
y=1/(b-a);
m=(a+b)/2;
s=((b-a)^2)/12;
disp('mean is ');m
disp('variance is ');s
disp('value of f(x) is ');y
u=[zeros(1,(a-1)) ones(1,(b-a)) zeros(1,(n-b))];
z=y*u;
stem(z);
axis([0 n 0 1]);



Example of Output
Input the end value of x = 10
Input the starting value of uniform distribution, a=2
Input the ending value of uniform distribution, b= 8
mean is 
m =
    5

variance is 
s =
    3

value of f(x) is 
y =
   0.1667

______________________________

If you find this program code useful, then please deposit 5 Indian Rupees in my bank account, as my fee. (Citizens of Pakistan cannot do this.).
I am the woman who wrote this program code.
My name: Anju K.
My bank account number: 30221619108
Bank: State Bank of India, Chakkarakkal branch, India.
IFSC code: SBIN0070728
SWIFT code: SBININBB
BIC code: SBININBB
My email: tc9749@gmail.com .


MATLAB Program for Random sequence generation

Program Code
%Random Sequence Generation
clc;
close all;
clear all;
n=input('Input the length of Random sequence ');
y=linspace(1,n,n);
disp(y);
x=0+sqrt(1)*randn(1,n);
disp(x);
plot(y,x);
axis([1 10 -1.5 3.5]);
title('Random Sequence');
xlabel('Discrete Frequency');
ylabel('Amplitude');
grid on;



Example of Output

Input the length of Random sequence   13
     1     2     3     4     5     6     7     8     9    10    11    12    13

  Columns 1 through 7 
   -0.4326   -1.6656    0.1253    0.2877   -1.1465    1.1909    1.1892

  Columns 8 through 13 
   -0.0376    0.3273    0.1746   -0.1867    0.7258   -0.5883



_________________________________


If you find this program code useful, then please deposit 5 Indian Rupees in my bank account, as my fee. (Citizens of Pakistan cannot do this.).
I am the woman who wrote this program code.
My name: Anju K.
My bank account number: 30221619108
Bank: State Bank of India, Chakkarakkal branch, India.
IFSC code: SBIN0070728
SWIFT code: SBININBB
BIC code: SBININBB
My email: tc9749@gmail.com .