6. Amplitude Reversal & finding local maxima & local minima (MATLAB)

Amplitude Reversal & finding local maxima & local minima 


Objective:

Amplitude Reversal & finding local maxima & local minima.

Take an input signal from the user and find the local minima and maxima of the signal for the particular time interval using the ‘findpeaks’ command and amplitude reversal technique. Take time intervals and steps from the user.

Since the original signal might not have local maxima/minima or may be only one, so add a random error to the original signal and then find minima and maxima of that signal too.

Then plot both graphs.


Purpose:

In mathematical analysis, the maxima and minima of a function, known collectively as extrema, are the largest and smallest value of the function, either within a given range, or on the entire domain.

There are numerous practical applications in which it is desired to find the maximum or minimum value of a particular quantity. Such applications exist in economics, business, and engineering. Many can be solved using the methods of differential calculus described above. For example, in any manufacturing business it is usually possible to express profit as a function of the number of units sold.

Finding maxima or minima also has important applications in linear algebra and game theory. For example, linear programming consists of maximizing (or minimizing) a particular quantity while requiring that certain constraints be imposed on other quantities. The quantity to be maximized (or minimized), as well as each of the constraints, is represented by an equation or inequality. The resulting system of equations or inequalities, usually linear, often contains hundreds or thousands of variables.

Everything in this world is based on the concept of maxima and minima, every time we always calculate the maximum and minimum of every data. Now-a-days results are also based on the concepts of grades which is again based on the concept of maxima and minima.


Learning Outputs:

1. I have learnt the use of ‘findpeaks’ command to find maxima of a signal.

2. I have learnt the amplitude reversal technique.

3. I have learnt plotting commands like plot, subplot, linewidth, hold on.

4. I have learnt to generate a random number and manipulate with the given signal.

5. I have learnt to make a menu driven program to make it easy for the user to use the program

6. I have learnt to implement mind logics and solve a complicated maths problem on MATLAB.


CODE:

clc

clear all

close all

t_lower=input('Enter Lower Time Limit: ');

t_upper=input('Enter Upper Time Limit: ');

t_step =input('Enter TIme Step: ')

t = t_lower:t_step:t_upper;

x = input('Enter a Signal function in terms of "t": ')

disp(x)

subplot(2,1,1)

plot(t,x,'r');

hold on;

%finding and plotting local maxima

[a,b]=findpeaks(x);

plot(t(b),x(b),'bo','linewidth',2);

hold on;

%finding and plotting local minima

a=-x;

[a,b]=findpeaks(a);

plot(t(b),x(b),'go','linewidth',2);

xlabel('Time');

ylabel('Amplitude');

title('Original Signal')

legend('Original Input Signal','Local Maxima','Local Minima');

grid on;

%This part of the program add some error in the original function

%and then prints the results for better understanding of the concept

e=rand(1,length(t)); %some noise to add in signal

x=x+e

subplot(2,1,2)

plot(t,x,'r');

hold on;

%finding and plotting local maxima

[a,b]=findpeaks(x);

plot(t(b),x(b),'bo','linewidth',2);

hold on;

%finding and plotting local minima

a=-x;

[a,b]=findpeaks(a);

plot(t(b),x(b),'go','linewidth',2);

xlabel('Time');

ylabel('Amplitude');

title('Original Signal with some added noise')

legend('Input Signal','Local Maxima','Local Minima');

grid on


OUTPUT:



Enter Lower Time Limit: 0

Enter Upper Time Limit: 10

Enter TIme Step: 0.1

Enter a Signal function in terms of "t": sin(t)


To download MATLAB code file and project report (CLICK HERE)

Comments