Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

repeat wave- pls help!

Status
Not open for further replies.

Tomas6

Electrical
Nov 9, 2005
1
Does anyone know how to change the frequency of this square wave? I don't want to use the Matlab square(T) function. I'm pretty sure there is more code needed to add to this.
When I chenge the line y = [ones(L/2),zeros(L/2)]; to
y = [ones(L/4),zeros(L/4)]; it won't plot.
I'm stumped.
Thanks for help-
Tom

x = 1:100;
L = length(x);
y = [ones(L/2),zeros(L/2)];
plot(x,y)
 
Replies continue below

Recommended for you

Don't you think you need to fill y some more? You've only assigned half the values

TTFN



 
Check the help information for the "ones" and "zeros" functions. The statement "ones(L/2)" produces a L/2 x L/2 matrix of ones NOT a L/2 x 1 vector of ones. Your variable y is of dimensions 50 x 100. Is that what you really want?

M

--
Dr Michael F Platten
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor