登录论坛

查看完整版本 : 如何在Matlab中使用circshift?我究竟做错了什么?


poster
2019-12-10, 20:30
我想在Matlab中绘制“油腻的”测试信号,然后在同一图中绘制高斯函数。下面的脚本可以做到这一点。

但是我希望能够将Gauss函数放置在某个位置,因此我看到其他人经常使用CIRCSHIFT来移动绘图。

使用它时,我可以将高斯功能向左或向右移动,但不能上下移动。

脚本中使用的PGAUSS来自LTFAT DSP第三方工具箱,但是它可以用于调试任何功能。例如-x ^ 2。

有人可以找出我在做什么错吗?

这是[0 0] 替代文字的 (http://img268.imageshack.us/img268/1130/66837635.png)样子http://img268.imageshack.us/img268/1130/66837635.png

[0 111] 替代文字的 (http://img684.imageshack.us/img684/2386/0111q.png)外观如下: http://img684.imageshack.us/img684/2386/0111q.png (http://img684.imageshack.us/img684/2386/0111q.png)

这是[111 0] 替代文字的 (http://img194.imageshack.us/img194/8760/1110d.png)外观http://img194.imageshack.us/img194/8760/1110d.png

很多爱,路易丝

g = greasy; fs = 16000; Lg = length(g); % -2441 so just get the first 500 points L2 = floor(Lg/2)+1 - 2441; gf = greasy; gf = gf(1:L2); hold on plot (1:L2,gf); xlabel('Time / samples'); ylabel('Amplitude'); % Contructing values to make the plot look as desired L = 500; tfr = 1; cent = 300; %gw = pgauss(L,tfr,cent) % Here I would have expected the Gauss function to be % moved down, but nothing happens. gw = circshift(pgauss(L,tfr,cent), [0 -1]); plot(gw,'Color','red'); % Multiply the signal with the Gauss window figure(2); plot(gf.*gw);

回答:

您想要做的是向高斯函数添加一个常数因子以向上或向下移动它。

B = [1,2,3,4,5]

B =

1 2 3 4 5

尺寸(B)

回答=

1 5

circshift(B,[2 0])

它什么也不做,因为B只有一行,所以无论rowshift的值如何,该行都会返回到其原始位置

回答=

1 2 3 4 5

circshift(B,[0 2])

回答=

4 5 1 2 3

B + 5

回答=

6 7 8 9 10



更多&回答... (https://stackoverflow.com/questions/1994984)