【发布时间】:2019-01-20 02:15:17
【问题描述】:
我需要根据根绘制一个函数,我可以使用 poly() 来获取多项式。但是,每当我运行该函数时,它都会给我一个错误。我希望能够修复错误,以便继续实现我的进一步目标。
我需要根据我提供的时间域绘制函数,根据采样指数 nVec 乘以采样率 deltaT 绘制函数,然后绘制离散信号。我现在停下来,因为我无法绘制连续信号(第一个图)。它一直给我一个错误。我尝试将根 (rootsVec) 从负包含更改为纯正,因此我可以从 poly() 中获得方程,并将采样率用于时间增量,但无济于事。
function [tVec,nVec,xVec] =
fxNthOrderPolyDTSignal(domainVec,noOfSamples,rootsVec)
DSIntervals = noOfSamples - 1;
deltaT = (max(domainVec) - min(domainVec))/DSIntervals;
%time = input("Please input a specific time within the domain: ");
nVec = min(domainVec)/deltaT;
tVec = min(domainVec) + (nVec * deltaT);
Eqtn = poly(rootsVec);
x = linspace(domainVec(1),0.5,max(domainVec));
figure(1)
plot(Eqtn(x),x)
figure(2)
plot(Eqtn,(nVec*deltaT))
end
预期结果只是带有以下输入参数的信号图: domainVec = [-10, 10](这是信号存在的时间);
noOfSamples = 30;
rootsVec = [-3, 8](又名二阶多项式);
实际结果如下错误:数组索引必须是正整数或逻辑值。
【问题讨论】: