All About Circuits Forum  

Go Back   All About Circuits Forum > Software, Microcomputing, and Communications Forums > Programmer's Corner

Notices

Programmer's Corner Discussion forum for all aspects of programming and software engineering. Any software programming language welcome: C, C++, C#, Fortran, Java, Matlab, etc.

Reply   Post New Thread
 
Thread Tools Display Modes
  #1  
Old 01-28-2010, 01:55 PM
dcwang3 dcwang3 is offline
New Member
 
Join Date: Nov 2009
Posts: 4
Default Matlab Help, generating square wave, and sinusoid

Hi:

I'm working on a matlab project, and I do not have too much knowledge in Matlab. Here is my problem:

-------
1) The sampling rate assumed in hw2channel is 10Mhz. This means that the time elapsed between two adjacent samples in any signal vector is 100ns. You have to keep this in mind when generating signals in MATLAB to test the channgel.

Generate an impulse, a square wave of fundamental frequency 1MHz, and a pure sinusoid of frequency 2.5MHz.

Hint1: In MATLAB, an impulse can represented by an 1 followed by many 0s.
Hint2: For the square wave and sinusoid, since we cannot have infinite length signal vectors in MATLAB, we have to truncate the signals to finite length. As a result when putting these finite-length signals through the channel, transient s will occurs at the beginning and the end. Here we will care mostly about the stead state responses. Hence you will need to generate long enough signal vectors to allow the transients to die down before observing the steady state responses.


----
Here is my code. I do not know if I am initializing it correct, and I am not sure what my t has to be.

Code:
fsample = 10e6;          %sample rate (Hz)
square_fs = 1e6;         %frequency of square wave is 1MHz
sinusoid_fs = 2.5e6;     %frequency of sinusoid is 2.5MHz


gen_impulse = [1,zeros(1,size(t))];       %generate impulse wave

gen_square = square(2*pi*square_fs*t);   %generate square wave

gen_sin = sin(2*pi*2.5e6*t)


Can someone help?

Thanks
Reply With Quote
Reply   Post New Thread

Bookmarks

Tags
, , , ,

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 10:28 PM.


User-posted content, unless source quoted, is licensed under a Creative Commons Public Domain License. Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.