how to plot two signal before convolve?

6 ビュー (過去 30 日間)
Neptune16
Neptune16 2019 年 9 月 29 日
コメント済み: Ajay Kumar 2019 年 9 月 29 日
how do I plot two signal of x1(t) and x2(t)?
x1(t) = 1 , 0<t<1
x2(t)={ 1, 0<t<1
2, 1<t<2
just like below picture

回答 (1 件)

Ajay Kumar
Ajay Kumar 2019 年 9 月 29 日
t1 = linspace(0, 1);
for i=1:length(t1)
if (0<t1(i)) && (t1(i)<1)
x1(i) = 1;
else
x1(i) = 0;
end
end
t2 = linspace(0, 2);
for j=1:length(t2)
if (0<t2(j)) && (t2(j)<1)
x2(j) = 1;
elseif (1<t2(j)) && (t2(j)<2)
x2(j) = 2;
else
x2(j) = 0;
end
end
figure(1);
plot(t1,x1);
figure(2);
plot(t2,x2);
I know that there are more efficient and simple ways, but I am also new to MATLAB and currently learning. So, I tried it in my way.
  2 件のコメント
darova
darova 2019 年 9 月 29 日
There vertical lines that are not exactly vertical
img1.png
What we gonna do with this?
Ajay Kumar
Ajay Kumar 2019 年 9 月 29 日
You can increase number of points in t1 and t2.
try this.
replace t1 = linspace(0, 1, 1000); and t2 = linspace(0, 2, 2000);
Accept the answer if you got what you need. Thanks :)

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

カテゴリ

Help Center および File ExchangeMultirate Signal Processing についてさらに検索

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by