## electricalstudent Latest Articles

## generate AM signal in time domain and frequency spectrum using MATLAB

hwmadeeasyBelow is a good starting point for your program:

`% Clear and initialize variables`

clear

close all

hold off

N=2^18; % Number of sample points

Fs=2^14; % sample frequency is 16,384 Hz is to be power of 2

% because we are using the FFT and not the DFT

Ts=1/Fs;

fc=1000; % carrier frequency is 1 kHz

fm=100; Ac=10; % message frequency is 100 Hz, amplitude is 10

mu2=1.0; % 100% modulation

mu1=0.5; % 50% modulation

t=(0:N-1)*Ts; % Time vector

a complete executable matlab code is pasted below

(more…)## P2.4Let x(n) = {2,4, -3, 1, -5, 4, 7}. Generate and plot the samples (use the stem function) of the following sequences.

hwmadeeasyP2.4

Let x(n) = {2,4, -3, 1, -5, 4, 7}. Generate and plot the samples (use the stem function) of

the following sequences.

- x1(n) = 2x(n – 3) + 3x(n + 4) – x(n)
- x2 (n) = 4x(4 + n) + 5x(n + 5) + 2x(n)
- x3 (n) = x(n + 3)x(n – 2) + x(1 – n)x(n + 1)
- x4 (n) = 2e0.5𝑛x(n) + cos(0.1πn) x(n + 2) , -10 ≤ n ≤ 10

sigshift.m is required for this which is attached here

```
unction [y,n] = sigshift(x,m,n0)
% implements y(n) = x(n-n0)
% -------------------------
% [y,n] = sigshift(x,m,n0)
%
n = m+n0; y = x;
```

## P2.3Generate the following periodic sequences and plot their samples (using the stem function)over the indicated number of periods.

hwmadeeasyP2.3

Generate the following periodic sequences and plot their samples (using the stem function)

over the indicated number of periods.

- 1 x (n) = {. . . , -2, -1, 0, 1, 2, . . .}periodic. Plot 5 periods
- 2x (n) = 𝑒0.1𝑛[u(n) – u(n – 20]periodic. Plot 3 periods.
- 3x (n) = sin(0.1πn)[u(n) – u(n – 10)]. Plot 4 periods.
- 4 x (n) = {. . . , 1, 2, 3, . . .}periodic + {. . . , 1, 2, 3, 4, . . .}periodic, 0 ≤ n ≤ 24. What is

## Generate the following random sequences and obtain their histogram using the hist function with 100 bins. Use the bar function to plot each histogram.

hwmadeeasyGenerate the following random sequences and obtain their histogram using the hist function with 100 bins. Use the bar function to plot each histogram.

- x1(n) is a random sequence whose samples are independent and uniformly distributed over [0, 2] interval. Generate 100,000 samples.
- x2(n) is a Gaussian random sequence whose samples are independent with mean 10 and variance 10. Generate 10,000 samples.
- x3(n) = x1(n) + x1(n – 1) where x1(n) is the random sequence given in part 1 above. Comment on the shape of this histogram and explain the shape.
- x4(n) = Σy𝑘(n)4𝑘=1 where each random sequence y𝑘(n) is independent of others with samples uniformly distributed over [-0.5, 0.5]. Comment on the shape of this histogram.

## Generate the following sequences using the basic MATLAB signal functions and the basic MATLAB signal operations discussed in this chapter. Plot signal samples using the stem function.

hwmadeeasy- x1(n) = 3δ(n + 2) + 2δ(n) – δ(n – 3) + 5δ(n – 7), -5 ≤ n ≤ 15.
- x2(n) Σe−|k|5k=−5=δ(n – 2k), -10 ≤ n ≤ 10.
- x3(n) = 10u(n) – 5u(n – 5) – 10u(n – 10) + 5u(n – 15).
- x4(n) = e0.1n[u(n + 20) – u(n – 10)].
- x5(n) = 5[cos(0.49πn) + cos(0.51πn)], -200 ≤ n ≤ 200. Comment on the waveform shape.
- x6(n) = 2 sin(0.01πn)cos(0.5πn), -200 ≤ n ≤ 200. Comment on the waveform shape.
- x7(n) = e−0.05n sin(0.1πn + π/3), 0 ≤ n ≤ 100. Comment on the waveform shape.
- x8(n) = e0.01n sin(0.1πn), 0 ≤ n ≤ 100. Comment on the waveform shape.

```
function [x,n] = impseq(n0,n1,n2)
% Generates x(n) = delta(n-n0); n1 <= n,n0 <= n2
% ----------------------------------------------
% [x,n] = impseq(n0,n1,n2)
%
if ((n0 < n1) | (n0 > n2) | (n1 > n2))
error('arguments must satisfy n1 <= n0 <= n2')
end
n = [n1:n2];
%x = [zeros(1,(n0-n1)), 1, zeros(1,(n2-n0))];
x = [(n-n0) == 0];
```

## CEN464 Labs Lab 1: Sampling in the time domain using MALAB solved

hwmadeeasyA continuous-time sinusoidal wave is given by

x(t) = Acos(2⇡Ft + “). (1)

For A = 5, F = 10, ” = 0, and 0 < t < 1,

(a) Define and plot x(t) and |X(j!)|. For 0 t < 1, use a step size of 1

256 , and for −128 ! < 127 a

step size of 1. To approximate |X(j!)|, use abs(fftshift(fft(x))).

(b) Determine the maximum frequency of x(t) from the graph of |X(j!)|. Since the plot of x(t) goes from

0 to 1, you can also count the number of peaks from the plot of x(t). Verify that you get a frequency of

10 Hz as indicated in the question. Use the maximum frequency to determine the Nyquist sampling

frequency and period. Matlab deals with vectors and matrices. Therefore, to sample, we need to

know how many elements to skip before taking a sample. We will call this the Nyquist step size. It

can be calculated from the Nyquist period by multiplying the period with the step size 1

Verify

that the Nyquist step size is 12.8. Meaning, we need to take a sample every 12 elements of the vector

x. Any more skipping and we violate the Nyquist condition.

(c) Oversample x(t) to obtain x[n] and plot it. To oversample, use a step size of 2 (much smaller than 12.8).

Reconstruct x(t) from x[n] by calling the provided sinc interpolator function (i.e., sincinterp()) to

obtain xr(t). Since you want the reconstructed signal to have the same size as x(t), pass N = 256

to sincinterp(). Find and plot |Xr(j!)| along with x[n] and xr(t). Find the maximum frequency

of the reconstructed signal from the graphs of x(t) and |X(j!)|. Is it still 10 Hz? If not, what is the

new frequency? Is this expected? Explain.

(d) Critically sample x(t) by repeating part (c) with a step size of 12. Note that it is very close to the

Nyquist step size (related to the Nyquist period).

(e) Undersample x(t) and repeat part (c) with a step size of 15. Note that it is larger than the Nyquist

step size. Verify that the frequency of the reconstructed signal is smaller than the original signal.

What is this phenomenon called?

## write a Matlab program to show both sampling and reconstruction using a truncated Gaussian pulse signal

hwmadeeasywrite a Matlab program to show both sampling and reconstruction using a truncated Gaussian pulse signal

(more…)## what is BJT series voltage regulator and derive for its line regulation and load regulation?

hwmadeeasyA device which maintains the output voltage of an ordinary power supply constant irrespective of load variations or changes in input a.c. voltage is known as a voltage regulator. The figure shown below is a simple series voltage regulator using a transistor ...