【问题标题】:Output argument "y" (and maybe others) not assigned during call调用期间未分配的输出参数“y”(可能还有其他参数)
【发布时间】:2015-10-25 18:21:31
【问题描述】:

我有这个任务:

编写一个名为 multioperations 的 Matlab 函数,它同时在图形上返回以下输出。 一种。幅度缩放信号 阿尔法、贝塔、伽马分别是用于定义移位、时间缩放和幅度缩放的尺度的变量。取输入信号 Asin(2π fn +φ ) 。 Alpha、beta 和 gamma 必须在运行时从用户那里获取。

这是我的代码:

    function [y,l]=multioperators(x,n)        
    prompt = 'Enter value for Shifting:\n Alpha=';
    alpha = input(prompt);
    a=alpha;
    function [u,k]=sigshift(x,n,a)        
    k=n+a;
    u=x;
    end
    prompt = 'Enter value for Time Scaling:\n Beta = ';
    beta = input(prompt);
    b=beta;
    function [s,t]=sigscale(u,k,b)        
    t=b/k;        
    s=u;   
    end
    prompt = 'Enter value for Amplitude Scaling:\n Gamma = ';
    gamma = input(prompt);
    c=gamma;   
    function[q,r]= sigamp(s,t,c)        
    r=t;        
    q=c*s;      
    end
    end

但是当我如下调用这个函数时,我得到一个错误:

    A=2;
    n=-10:0.01:10;
    phi=pi/2;
    f=0.01;
    x=A*sin(2*pi*f*n+phi);
    subplot(2,1,1);
    plot(n,x);
    [y,l]=multioperators(x,n);
    subplot(2,1,2)  
    plot(l,y)

我收到以下错误:

     Error in multioperators (line 3)
     prompt = 'Enter value for Shifting:\n Alpha=';

     Output argument "y" (and maybe others) not
     assigned during call to
    "C:\Users\mehak_raibail\Documents\MATLAB\multioperators.m>multioperators".

    Error in ex8_q3a (line 8)
    [y,l]=multioperators(x,n);

请给点建议。

【问题讨论】:

    标签: matlab


    【解决方案1】:

    您永远不会为变量y(也不是l)分配值,但是当您调用[y,l]=multioperators(x,n); 时,您希望它作为输出。

    此外,您还有从不调用的嵌套函数。你可能想看看doc

    【讨论】:

    • 非常感谢,文档有帮助
    猜你喜欢
    • 2013-10-04
    • 1970-01-01
    • 1970-01-01
    • 2017-12-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多