LabVIEW MathScript开发算法:第二部分——MathScript 交互式窗口

测试测量 时间:2017-01-06 来源:网络



  • 点击Script标签并点击Load按钮。选择Mitra P2_1.m(Mitra, Sanjit and Kaiser, James H.,数字信号处理手册Handbook for Digital Signal Processing[New York: John Wiley and Sons, 1993], 21)。该脚本生成一个测试信号并在该信号上应用滑动平均滤波器。
  • 点击Run按钮来运行该脚本,将出现Prompt User for Input对话框。在Desired length of the filter=文本框中输入正值并点击OK按钮。MathScript脚本可以包含交互式对话框来提示用户输入。
  • 下方显示的Mitra P2_1.m脚本,通过子绘图命令,指定绘图窗口(Plot window)内4幅子图(sub-plot)中的一幅。用户指定子图(sub-plot)后,后续命令随即影响该子图(sub-plot)。例如,当子绘图命令结束后,绘图命令可将其本身指定的绘图装入先前由子绘图命令指定的子图(sub-plot)。
  • % Program P2_1
    % Simulation of an M-point Moving Average Filter
    % Generate the input signal
    n = 0:100;
    s1 = cos(2*pi*0.05*n); % A low-frequency sinusoid
    s2 = cos(2*pi*0.47*n); % A high frequency sinusoid
    x = s1+s2;
    % Implementation of the moving average filter
    M = input(Desired length of the filter = );
    num = ones(1,M);
    y = filter(num,1,x)/M;
    % Display the input and output signals
    clf;
    subplot(2,2,1);
    plot(n, s1);
    axis([0, 100, -2, 2]);
    xlabel(Time index n); ylabel(Amplitude);
    title(Signal #1);
    subplot(2,2,2);
    plot(n, s2);
    axis([0, 100, -2, 2]);
    xlabel(Time index n); ylabel(Amplitude);
    title(Signal #2);
    subplot(2,2,3);
    plot(n, x);
    axis([0, 100, -2, 2]);
    xlabel(Time index n); ylabel(Amplitude);
    title(Input Signal);
    subplot(2,2,4);
    plot(n, y);
    axis([0, 100, -2, 2]);
    xlabel(Time index n); ylabel(Amplitude);
    title(Output Signal);
    axis;

    您可以使用Command Window文本框来找出更多命令信息。利用在Command Window文本框中键入help subplot,该命令的描述以及语法信息、输入、输出和示例将会出现在Output Window中。


    1 2

    关键词:LabVIEWMathScript开发算法交互式窗

    加入微信
    获取电子行业最新资讯
    搜索微信公众号:EEPW

    或用微信扫描左侧二维码

    相关文章


    用户评论

    请文明上网,做现代文明人
    验证码:
    查看电脑版