All posts by Ankur

Plotting Unit Impulse, Unit Step, Unit Ramp and Exponential Function in MATLAB

In this blog post, we will explore how to plot basic discrete-time signals in MATLAB, including the Unit Impulse, Unit Step, Unit Ramp, and Exponential Function. These fundamental signals are commonly used in signal processing and control systems.

Below is a MATLAB script that plots these four signals using the stem() function, which is used to display discrete-time signals.

t=-2:1:2;
y=[zeros(1,2), ones(1,1), zeros(1,2)];
subplot(2,2,1);
stem(t,y);
ylabel('d(n)');
xlabel('unit impulse');

n=input('Enter n values');
t=0:1:n-1;
y1=ones(1,n);
subplot(2,2,2);
stem(t,y1);
ylabel('Amplitude');
xlabel('unit step');

n=input('Enter n values');
t=0:1:n-1;
subplot(2,2,3);
stem(t,t);
ylabel('Amplitude');
xlabel('unit ramp');

n=input('Enter length of exponential seq');
t=0:1:n-1;
a=input('Enter a value');
y2=exp(a*t);
subplot(2,2,4);
stem(t,y2);
xlabel('Exponential fun');
ylabel('Amplitude');
Continue reading Plotting Unit Impulse, Unit Step, Unit Ramp and Exponential Function in MATLAB

Implementation of Bottom-Up (Shift-Reduce) Parsing in C++

This program implements a basic shift-reduce parser for parsing expressions based on given grammar rules. It reads a set of production rules and an input string, then attempts to reduce the input to the start symbol.

The process follows these steps:

  1. Shift input symbols onto a stack.
  2. Attempt to reduce the top of the stack based on the given production rules.
  3. Continue until the entire input is processed and reduced to the start symbol.
Continue reading Implementation of Bottom-Up (Shift-Reduce) Parsing in C++