Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

I need some help in MatLab

  1. Nov 23, 2007 #1
    Hey I'm new to this forum and I need some MatLab help. I need to make a unit step function , a triangle function, a rectangle function, and a saw function. How can I do that in MatLab? After that I need to find the Fourier series and transforms of those. Can anyone help me out?
  2. jcsd
  3. Nov 24, 2007 #2

    Dr Transport

    User Avatar
    Science Advisor
    Gold Member

    The unit step function is just a series of 0's and 1's. That is easily written either using a for loop, or concantenating two vectors together, almost the same thing for the rectangle function. Now the triangle function can either be written as a function, or more elegantly as the convolution of two rectangle functions. The saw-tooth is just a finite linear line concantinated with itself a bunch of times.

    As for the FFt's of these, they are very simple, Matlab has an FFT routine, just type in A =FFT(B) and they pop right out. If the input vectors are not powers of two long, there is another function, look in the help file, it is very very helpful, moreso than any I have ever seen.
  4. Nov 24, 2007 #3
    In the signal processing toolbox there are functions called "sawtooth" and "square" that generate certain waveforms. If you wanted to code your own or if you don't have the signal processing toolbox, you might look into using the functions "zeros" and "ones."
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook