|
|
|
As pointed in About,
" urge the reader to use/trust the content only after verifying it against standards and/or consulting it with experts in the field".
»
|
MATrix LABoratory
|
For me, MATLAB is a mathematical tool that allow me to understand
3GPP PHYsical layer implementation concepts with the help of its "Communication" toolbox.
|
MATLAB online
|
|
»
|
MATLAB resources
|
Best resources to learn and use MATLAB are available on their website
(documentation, examples, tutorials, queries-n-answers).
To begin with, you may start with below tutorial page
|
MATLAB tutorials
|
There is also "Get Started" page.
|
MATLAB Get Started
|
|
»
|
Draw a Circle in MATLAB
|
x = -1:1/100:1;
plot(x, sqrt(1 - x .* x))
hold on
plot(x, -sqrt(1 - x .* x))
axis equal
hold off
|
|
|
»
|
Draw a Cylinder in MATLAB
|
R = 2;
N = 10;
x = -R:R/N:R;
y = sqrt(R*R - x .* x);
z = ones(N*2+1,1) * x;
z = z';
surf(x,y,z)
axis equal
hold on
Y = -sqrt(R*R - x .* x);
surf(x,Y,z)
hold off
|
|
|
»
|
Draw a Sphere in MATLAB
|
N = 50;
R = 2;
theta = 0:pi/N:pi;
phi = 0:pi/N:pi;
[th, ph] = meshgrid(theta,phi);
X = sin(th).*cos(ph);
Y = sin(th).*sin(ph);
Z = cos(th);
surf(R*X,R*Y,R*Z);
axis equal
hold on
surf(R*X,-R*Y,R*Z);
hold off
|
|
|
»
|
Quadratic polynomial
|
%% Quadratic polynomial f(x) = x^2 - 8x + 20
%% with roots: 4 + j2 and 4 - j2
x = 0:.25:6;
y = -3:.25:3;
[X, Y] = meshgrid(x,y);
A = zeros(size(X));
for c1 = 1:size(X,1)
for c2 = 1:size(X,2)
Number = X(c1,c2) + 1i * Y(c1, c2);
A(c1, c2) = abs(Number^2 - 8*Number + 20);
end
end
f_of_x = mesh(X, Y, A);
xlabel('real');
ylabel('imag');
zlabel('f(x)');
|
|
|
»
|
Discrete-Time Sinusoid
|
%% Behaviour of Discrete-Time Sinusoid
n = -16:1:16;
figure(1);
tiledlayout(4,1);
nexttile;
w = 0;
stem(cos(w*n));
title('ω = 0');
nexttile;
w = w + pi/8;
stem(cos(w*n));
nexttile;
w = w + pi/8;
stem(cos(w*n));
nexttile;
w = w + pi/8;
stem(cos(w*n));
figure(2);
tiledlayout(4,1);
nexttile;
w = w + pi/8;
stem(cos(w*n));
title('ω = π/2');
nexttile;
w = w + pi/8;
stem(cos(w*n));
nexttile;
w = w + pi/8;
stem(cos(w*n));
nexttile;
w = w + pi/8;
stem(cos(w*n));
figure(3);
tiledlayout(4,1);
nexttile;
w = w + pi/8;
stem(cos(w*n));
title('ω = π');
figure(4);
tiledlayout(4,1);
nexttile;
w = w + pi/8;
stem(cos(w*n));
nexttile;
w = w + pi/8;
stem(cos(w*n));
nexttile;
w = w + pi/8;
stem(cos(w*n));
nexttile;
w = w + pi/8;
stem(cos(w*n));
title('ω = 3π/2');
figure(5);
tiledlayout(4,1);
nexttile;
w = w + pi/8;
stem(cos(w*n));
nexttile;
w = w + pi/8;
stem(cos(w*n));
nexttile;
w = w + pi/8;
stem(cos(w*n));
nexttile;
w = w + pi/8;
stem(cos(w*n));
title('ω = 2π');
|
|
|
»
|
Sampling of a sinusoid
|
%% sampling
granularity = 2^12;
time = 0:pi/granularity:1;
sampling_frequency = 32;
number_of_sampling_values = size(time, 2)/sampling_frequency;
figure(1);
tiledlayout(4,1);
nexttile;
frequency = 1;
plot(cos(2*pi*time*frequency));
title("frequency = " + frequency);
xticklabels([]);
nexttile;
cosine_values = cos(2*pi*time*frequency);
sampled = cosine_values(1:number_of_sampling_values:end);
stem(sampled);
title("sampling frequency = " + sampling_frequency);
nexttile;
frequency2 = 2;
plot(cos(2*pi*time*frequency2));
title("frequency = " + frequency2);
xticklabels([]);
nexttile;
cosine_values = cos(2*pi*time*frequency2);
sampled = cosine_values(1:number_of_sampling_values:end);
stem(sampled);
title("sampling frequency = " + sampling_frequency);
|
|
|
»
|
Aliasing
|
%% aliasing
granularity = 2^12;
time = 0:pi/granularity:1;
sampling_frequency = 32;
number_of_sampling_values = size(time, 2)/sampling_frequency;
figure(1);
tiledlayout(4,1);
nexttile;
frequency = 2;
plot(cos(2*pi*time*frequency));
title("frequency = " + frequency);
xticklabels([]);
nexttile;
cosine_values = cos(2*pi*time*frequency);
sampled = cosine_values(1:number_of_sampling_values:end);
stem(sampled);
title("sampling frequency = " + sampling_frequency);
nexttile;
frequency2 = (sampling_frequency/2) + (sampling_frequency/2 - frequency);
plot(cos(2*pi*time*frequency2));
title("frequency = " + frequency2);
xticklabels([]);
nexttile;
cosine_values = cos(2*pi*time*frequency2);
sampled = cosine_values(1:number_of_sampling_values:end);
stem(sampled);
title("sampling frequency = " + sampling_frequency);
|
|
|
»
|
Discrete-Time Convolution sum
|
%% Discrete-time Convolution sum
sample_n1 = 0:1:8;
unit_impulse_reponse = [ 0 0 1 2 3 0 1 0 0];
input_signal = [ 0 1 1 2 2 2 1 1 0 ];
convolution_sum = conv (input_signal, unit_impulse_reponse);
sample_n2 = 0:length(convolution_sum)-1;
figure(1);
subplot(3,1,1)
stem(sample_n1, input_signal)
title('Input signal')
subplot(3,1,2)
stem(sample_n1, unit_impulse_reponse)
title('Unit impulse response');
subplot(3,1,3)
stem(sample_n2, convolution_sum)
title('Convolution sum i.e response to input signal');
|
|
|
© Copyright Samir Amberkar 2018-24
| |
|
|
|