20.01.2015 Views

njit-etd2003-081 - New Jersey Institute of Technology

njit-etd2003-081 - New Jersey Institute of Technology

njit-etd2003-081 - New Jersey Institute of Technology

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

259<br />

B.2 MATLAB Programs<br />

This section provides the listing <strong>of</strong> different MATLAB programs used for analysis in this<br />

dissertation.<br />

B.2.1 Test Signal <strong>of</strong> Three Sinusoids at 0.3, 0.1 and 0.5 Hz<br />

This MATLAB program generates a test signal <strong>of</strong> three sinusoids with frequencies <strong>of</strong> 0.3,<br />

0.1 and 0.5 Hz and saves the output signal in an ASCII file called signal_3.asc.<br />

% signal.m<br />

% This is the source code for creating three different signals which each signal<br />

% is made <strong>of</strong> three sine wave with frequencies <strong>of</strong> 0.2, 0.5 and 1.0 Hertz. The<br />

% sampling frequency for the all signals is 200 samples per second.<br />

% Each signal is located as a one column <strong>of</strong> matrix sig_tes. The length <strong>of</strong> FFT is<br />

% 2048 points.<br />

% The plots <strong>of</strong> power spectrum are zoomed in. The last two lines <strong>of</strong> the instructions<br />

% is used to save the figures in Metafile format and then is imported to Micros<strong>of</strong>t<br />

% word (ver. 6.0a).<br />

V-0:0.005:29.99;<br />

signal_3=[sin(2*pi*0.3*t)zeros(1,1000)sin(2*pi*0.1*Ozeros(1,1000) sin(2*pi*0.5*t)]';<br />

ref=length(signal_3);<br />

Pyy=abs(fft(signal_3,4096));<br />

F=(200*(0:63)/4096)'; %sampling rate 200 sps<br />

T=(ref/200)/(ref-1)*(0:ref-1);<br />

figure(1);<br />

plot(T,signal_3,'r');xlabel('Time(second)');ylabel('Amplitude');<br />

pause<br />

figure(2);<br />

plot(F,Pyy(1:64),'r');xlabel('Frequency(Hertz)');ylabel('Power Density');<br />

save signal_3.asc signal_3 -ascii;

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!