Matlab Basic
Array generation
1 | a = linspace(1,11,5); |
For loop
1 | x = [1:0.1:10]; |
While loop
1 | x = [1:0.01:10]; |
Vectorization
1 | x = [1:0.01:10]; |
Element wise operations
1 | x = [1:1:10]; |
Logical operations
1 | x = [1:1:10]; |
Histogram
histogram(X,nbins)
1 | x = randn(10000,1); %creates 10000 independent standart normal RVs |
Stem plots
1 | figure(3); |
Regular plots
1 | figure(4); |
Subplot
1 | figure(5); |
Functions
1 | x = [1:2:10]; |
Create Bernouli
1 | function X = create_bernouli(p,n,m) % n X m matrix with each element bernouli p |