matlab- generate a periodic and aperiodic waveforms

Posted on 2006-04-16
Last Modified: 2016-02-10
How can I use matlab to generate a "periodic" and "aperiodic" waveform?

the "periodic" and "aperiodic" waveform can be any giving or use matlab to create them. After have those 2 waveforms, use matlab to plot it.
Question by:hsuyf
    LVL 2

    Expert Comment

      Huh? Where's the problem?
       In two dimensions, try the following, which I have just happened to have available:

    [X,Y] = meshgrid(0:.1:5,-1:.1:4);    <-prepares a sortof collection of (x,y) points.

    z = X.^2 - 4.*X + Y.^2 - Y - X.*Y;  <-Calculates some function at every such point, saving in z

    surfc(X,Y,z);view([1,1,1]);              <-Plots a surface, z = f(x,y)

       What do you mean by periodic and aperiodic? A function f(x) = x**2 which is not periodic can be made into a periodic function by repeating its x-parameter, that is, say
       F(x) = f(x) for 0 <= x < 1,
              = f(x - 1) for 1 <= x < 2,
              = f(x - 3) for 2 <= x < 3, etc.
       It is considered polite to avoid discontinuities at the chop points, but no matter.
       Conversely, a periodic function, such as sine(x) can be made aperiodic by computing sine(exp(x))
       Endless, endless possibilities.
    LVL 2

    Accepted Solution

    I'm not sure whether by periodic you mean periodic sampling, or periodic signal shape.  So this response covers both possibilities.

    You should aim to get your waveforms into two Matlab arrays (called say "waveformPeriodic" and "waveformAperiodic") which each have 2 columns, but do not necessarily have the same number of rows.  The first column of each array will hold the sample times.

    The following code will generate some example arrays :
       >> t1 = [1:100]';
       >> waveformPeriodic = [t1,sin(t1/10)];
       >> waveformAperiodic = [sort(rand(100,1)*100),rand(100,1)];

    Now for the plotting :
       >> figure
       >> plot(waveformPeriodic(:,1),waveformPeriodic(:,2),'.-',waveformAperiodic(:,1),waveformAperiodic(:,2),'.-');
       >> zoom on;

    Type ">>help plot" for more information on Matlab's plot command.  Note that I have set the linestyles to '.-' so that you can see the individual sample points.

    Good luck.

    Author Comment

    Thank you for your hlep. After I have this waveform, I have couple additional questions which regard to my project. I will post it later today. could you please help me more about this matlab. I have never touch matlab, but i really need slove asap. Thanks again

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Have you ever thought of installing a power system that generates solar electricity to power your house? Some may say yes, while others may tell me no. But have you noticed that people around you are now considering installing such systems in their …
    We are taking giant steps in technological advances in the field of wireless telephony. At just 10 years since the advent of smartphones, it is crucial to examine the benefits and disadvantages that have been report to us.
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now