zoukankan      html  css  js  c++  java
  • DSP

    This example shows how to find the root mean square (RMS) value of a sine wave, a square wave, and a rectangular pulse train using rms. The waveforms in this example are discrete-time versions of their continuous-time counterparts.

    Create a sine wave with a frequency of π/4 rad/sample. The length of the signal is 16 samples, which equals two periods of the sine wave.

    n = 0:15;
    x = cos(pi/4*n);

    Compute the RMS value of the sine wave.

    rmsval = rms(x)
    rmsval = 0.7071
    

    The RMS value is equal to 1/2, as expected.

    Create a periodic square wave with a period of 0.1 seconds. The square wave values oscillate between 2 and 2.

    t = 0:0.01:1;
    x = 2*square(2*pi*10*t);
    
    stem(t,x,'filled')
    axis([0 1 -2.5 2.5])

    Find the RMS value.

    rmsval = rms(x)
    rmsval = 2
    

    The RMS value agrees with the theoretical value of 2.

    Create a rectangular pulse train sampled at 1 kHz with the following parameters: the pulse is on, or equal to 1, for 0.025 seconds, and off, or equal to 0, for 0.075 seconds in each 0.1 second interval. This means the pulse period is 0.1 seconds and the pulse is on for 1/4 of that interval. This is referred to as the duty cycle. Use pulstran to create the rectangular pulse train.

    t = 0:0.001:(10*0.1);
    pulsewidth = 0.025;
    pulseperiods = [0:10]*0.1;
    x = pulstran(t,pulseperiods,@rectpuls,pulsewidth);
    
    plot(t,x)
    axis([0 1 -0.5 1.5])

    Find the RMS value and compare it to the RMS of a continuous-time rectangular pulse waveform with duty cycle 1/4 and peak amplitude 1.

    rmsval = rms(x)
    rmsval = 0.5007
    
    thrms = sqrt(1/4)
    thrms = 0.5000
    

    The observed RMS value and the RMS value for a continuous-time rectangular pulse waveform are in good agreement.

    Reference,

      1. MathWorks

  • 相关阅读:
    Sql2008 全文索引 简明教程
    sql server 全文检索 使用
    数据库分词查询的优缺点以及英文和中文各自的分词方法(一)
    win10中打开SQL Server配置管理器方法
    Asp.net 中高亮显示搜索关键字简单方法
    EntityFramework优缺点
    LoadXml载入Xhtml文件速度很慢
    c#无限循环线程如何正确退出
    线程的等待方法:join
    C#如何优雅的结束一个线程
  • 原文地址:https://www.cnblogs.com/zzyzz/p/13466659.html
Copyright © 2011-2022 走看看