How to plot a time-delayed ersion of a signal ??

1 回表示 (過去 30 日間)
Negar
Negar 2011 年 3 月 31 日
コメント済み: Amit Aryal 2015 年 3 月 27 日
cananyone tell me how to plot the time-delayed version of a signal ?
Imagine the simplest case, y=cos(x), I want to delay it by 2 units. But I get some strange results!
clc ; clear all; close all x=(0.00001:0.01:2)*pi; y=cos(x); plot(x,y) hold on [Nrow Ncol]=size(y); m=2; % Delay step z=zeros([Nrow Ncol]); for i=3:Ncol-m j=i-m; z(i,1)=y(j,1);
end plot(z,'r')
  1 件のコメント
Jan
Jan 2011 年 3 月 31 日
Please use code formatting to improve the readability of the code.
"Some strange results" is a vague description only. It is always a good idea to describe the results with as much details as needed to solve the problem.

サインインしてコメントする。

採用された回答

Paulo Silva
Paulo Silva 2011 年 3 月 31 日
x=0:0.01:2*pi
y=cos(x)
plot(x,y)
hold on
d=2;
y=[ones(1,d)*nan y(1:end-d)];
plot(x,y,'r')
legend('signal',['delayed signal by' num2str(d) 'units'])
  5 件のコメント
Negar
Negar 2011 年 3 月 31 日
Thanks a lot :)
Amit Aryal
Amit Aryal 2015 年 3 月 27 日
x=0:0.01:2*pi y=cos(x) plot(x,y) hold on d=2; y=[ones(1,d)*nan y(1:end-d)]; plot(x,y,'r') legend('signal',['delayed signal by' num2str(d) 'units'])
I tried the above code but no delay signal produced. Both signals superimposed one on top of another!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by