MatLab Programs - IMPULSE - STEP - SINE - COSINE -TRIANGULAR - SAWTOOTH - EXPONENTIAL SIGNALS GROWING DECAYING -

ElecDude ED | Friday, December 21, 2012 | 1 comments



 MatLab Programs

 
In this post the matlab code for basic DSP signal generation  are available. These are tested and outputs are also added.
  • Impulse signal
  • Step signal (Delayed Step)
  • Sine signal
  • Cosine signal
  • Triangular signal
  • Sawtooth signal
  • Exponential signals growing & decaying



Matlab code for unit impulse signal generation:
clc;
clear all;
close all;
disp('Unit Impulse Signal Generation');
N=input('Enter no of samples: ');
n=-N:1:N;
x=[zeros(1,N),1,zeros(1,N)];
stem(n,x);
xlabel('Sample');
ylabel('Amplitude');
title('Unit Impulse Signal');

In this, the impulse is generated by using ZEROS(x,y) function, which produces an array of size X,Y with all elements as ZERO.

 OUTPUT:


 Matlab code for unit ramp signal generation:

clc;

clear all;
close all;
disp('Unit Ramp Signal Generation');
N=input('Enter no of samples: ');
a=input('      Max Amplitude: ');
n=-N:1:N;
x=a*n/N;
stem(n,x);
xlabel('Sample');
ylabel('Amplitude');
title('Unit Ramp Signal');


  OUTPUT:





 Matlab code for unit step (delayed step) signal generation:

 clc;

clear all;

close all;
disp('Delayed Unit Step Signal Generation');
N=input('Enter no of samples: ');
d=input('Enter  delay  value: ');
n=-N:1:N;
x=[zeros(1,N+d),ones(1,N-d+1)];
stem(n,x);
xlabel('Sample');
ylabel('Amplitude');
title('Delayed Unit Step Signal');
  OUTPUT:



Matlab code for discrete sinusoidal signal generation:
clc;
clear all;
close all;
disp('Sinusoidal Signal generation');
N=input('Enter no of samples: ');
n=0:0.1:N;
x=sin(n);
figure, stem(n,x);
xlabel('Samples');
ylabel('Amplitude');
title('Sinusoidal Signal');
    
The SIN(n) function returns an array which corresponds to sine value of the array ‘n’
 OUTPUT:



Matlab code for discrete cosine signal generation:

clc;
clear all;
close all;
disp('Cosine wave generation');
N=input('Enter no of samples');
n=0:0.1:N;
x=cos(n);
figure, stem(n,x);
xlabel('Samples');
ylabel('Amplitude');
title('Cosine');


The COS(n) function returns an array which corresponds to cosine value of the array ‘n’
 OUTPUT:


Matlab code for  Trinangular or Sawtooth signal generation:


clc;clear all;
n=input('Enter the no samples: ');
x=0:0.1/n:20;

s=sawtooth(x);
t=sawtooth(x,0.5); % width=0.5 for Triangular signal

subplot(2,1,1),
plot(x,s),
xlabel('Time'),
ylabel('Amplitude'),
title('Sawtooth signal');

subplot(2,1,2),
plot(x,t),title('Triangular signal'),
xlabel('Time'),
ylabel('Amplitude');


 OUTPUT:



Matlab code for  exponentially decaying signal generation:


clc;
clear all;
close all;
disp('Exponential decaying signal');
N=input('Enter no of samples: ');

a=1;
t=0:0.1:N;
x=a*exp(-t);
figure,plot(t,x);
xlabel('Time');
ylabel('Amplitude');
title('Exponentially Decaying Signal');

 OUTPUT:




Matlab code for  exponentially growing signal generation:
 clc;
clear all;
close all;
disp('Exponential growing signal');
N=input('Enter no of samples: ');
a=1;
t=0:0.1:N;
x=a*exp(t);
figure,stem(t,x);
xlabel('Time');
ylabel('Amplitude');
title('Exponentially Decaying Signal');

 OUTPUT:


Viewers  comments are encouraged. 
This helps us to much more.
Thank you!!!


Category: ,

About GalleryBloggerTemplates.com:
GalleryBloggerTemplates.com is Free Blogger Templates Gallery. We provide Blogger templates for free. You can find about tutorials, blogger hacks, SEO optimization, tips and tricks here!

1 comment:

Search Here...

Loading...

Labels

materials (33) VLSI (31) jobs (23) embedded (22) NONGOVT (19) Govtjob (18) avr (18) Verilog codes (14) circuit ideas (11) Ebook (9) vhdl (7) PPT (6) elec softwares (6) c (5) projects (5) General (4) RESULTS (4) circuit lab (4) avr studio (3) gate (3) placements (3) 8051 self learn (2) DIY (2) ISRO (2) SERIAL COMMUNICATION USING AVR ATMEGA8 (2) microcontroller (2) 24Vdc 3A - Voltage regulator - circuit schematic diagram (1) 555 calculator (1) 7 SEGMENT VLSI CODE (1) 8051 programmer serial port (1) 8051 tutorial part1 (1) 8051 tutorial part2 (1) ALU VLSI CODE (1) ANSWER KEY FOR GATE 2012 -GATE 2012 ANSWER KEY (1) APPLICATION ENGINEER -TRAINEE - Corel Technologies (1) AVR SPI (1) About MAX7219 display driver (1) Administrative Officers (Scale-I) - NATIONAL INSURANCE COMPANY LIMITED - ONLINE Recruitment (1) Android (1) BOOTH MULTIPLIER (1) GROUP DISCUSSION - TECHNIQUES & TIPS (1) GUIDE LINE FOR FRESH ENGINEERING STUDENTS (1) IMAGE FILE TO TEXT FILE CONVERSION MATLAB – TEXT FILE TO IMAGE FILE CONVERSION MATLAB EXAMPLE (1) IMAGE PROCESSING IN VERILOG - ADD IMAGES IN VERILOG - MATLAB XILINX MODELSIM (1) MODELSIM TUTORIAL – WORKING WITH TESTBENCH – GETTING STARTED (1) MatLab Programs - IMPULSE - STEP - SINE - COSINE -TRIANGULAR - SAWTOOTH - EXPONENTIAL SIGNALS GROWING DECAYING (1) Microchip (1) QUALITIES AND PERSONALITIES FOR GOOD PERSON & SOME EMPLOYEE AND GET HIRED (1) SPI Working Modes of Operation - Verilog Code - Applications - Advantages Disadvantages (1) SPI verilog code master code slave code testbench. (1) Simple CGPA Calculator for Engg Colleges Anna university (1) TRAFFIC LIGHT CONTROLLER VLSI CODE (1) TRANSISTOR CODES AND CHOOSING (1) Tanner tutorial P1 (1) UNIVERSAL SHIFT REG VHDL CODE (1) VCD Description - Export VCD in Xilinx Modelsim - Example (1) XILINX 13.2 TUTORIALS (SELF LEARNING MATERIAL ) (1) avr calculator (1) avr serial header (1) chat (1) electronics (1) vhdl image processing add image (1)