0

尝试在同一轨迹内生成具有多个不同幅度历元的正弦函数。

例如,2Hz 正弦波以幅度 1 持续 10 秒,幅度 10 持续 10 秒,然后再回到幅度 1 持续 10 秒。

我尝试在这里编辑示例:http: //www.mathworks.se/help/slcontrol/ug/frest.sinestream.html 但代码出错:

input = frest.Sinestream('Frequency',[2 2 2],...
         'Amplitude',[1 10 1],...
         'FreqUnits','Hz',...
         'SamplesPerPeriod',[40 40 40],...
         'RampPeriods',[0 0 0],...
         'SettlingPeriods',[1 1 1]);
      plot(input)

从中收到的错误是:

Error using frest.Sinestream/set.Frequency (line 127)
The "Frequency" parameter of a sinestream signal should be a double vector consisting of unique values.

Error in frest.Sinestream/initializeParams (line 508)
                obj.(varargin{2*ct-1}) = varargin{2*ct};

Error in frest.Sinestream (line 80)
            obj = initializeParams(obj,inputparams{:});

Error in sine (line 1)
input = frest.Sinestream('Frequency',[2 2 2],...
4

1 回答 1

3

我想可能就这么简单:

x=0:0.005:30;
y = sin(x*2000);

idx = 10<x & x < 20;
y(idx) = 10*y(idx);

plot(x,y)

当然,如果那里的值不为零,这可能会在变化点处产生一些粗略的过渡。此示例说明了这一点:

x=0:0.005:30;
y = sin(x);

idx = 10<x & x < 20;
y(idx) = 10*y(idx);

plot(x,y)
于 2013-11-05T13:13:47.870 回答