Multiplication of two different continuous signal in Matlab

30 ビュー (過去 30 日間)
Aishwarya Bannai
Aishwarya Bannai 2021 年 5 月 12 日
回答済み: ghomer 2023 年 7 月 17 日
Hello,
I am trying to multiply a continous periodic sine wave to that of a rectangular pulse, But I see the error that the matrix dimensions must agree, Is it possible to multiply two different signals in MATLAB? can you please help me with one example code? or may be the commands that could be helpful.
x = 0:0.05:6;
y = sin(x)
subplot(3,1,1)
plot(x,y)
t1 = 0:0.05:1;
t2 = 1:0.05:2;
t3 = 2:0.05:3;
t4 = 3:0.05:4;
t5 = 4:0.05:5;
t6 = 5:0.05:6;
t=[t1 t2 t3 t4 t5 t6];
x1 = ones(size(t1));
x2 = zeros(size(t2));
x3 = ones(size(t3));
x4 = ones(size(t4));
x5 = zeros(size(t5));
x6 = ones(size(t6));
xs = [x1 x2 x3 x4 x5 x6]
subplot(3,1,2)
plot(t,xs);
ylim([-0.5 6])
%
% mul = xs.*y;
% subplot(3,1,3)
% plot(t,mul)
% ylim([-0.5 6])
The present code is this
Thank you

採用された回答

Stephan
Stephan 2021 年 5 月 12 日
編集済み: Stephan 2021 年 5 月 12 日
You made a mistake in defining t2...t6:
x = 0:0.05:6;
y = sin(x);
subplot(3,1,1)
plot(x,y)
t1 = 0:0.05:1;
t2 = 1.05:0.05:2;
t3 = 2.05:0.05:3;
t4 = 3.05:0.05:4;
t5 = 4.05:0.05:5;
t6 = 5.05:0.05:6;
t=[t1 t2 t3 t4 t5 t6];
x1 = ones(size(t1));
x2 = zeros(size(t2));
x3 = ones(size(t3));
x4 = ones(size(t4));
x5 = zeros(size(t5));
x6 = ones(size(t6));
xs = [x1 x2 x3 x4 x5 x6];
subplot(3,1,2)
plot(t,xs);
ylim([-0.5 6])
mul = xs.*y;
subplot(3,1,3)
plot(t,mul)
ylim([-0.5 6])
  1 件のコメント
Aishwarya Bannai
Aishwarya Bannai 2021 年 5 月 12 日
編集済み: Aishwarya Bannai 2021 年 5 月 18 日
Thanks a lot Stephan,

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

その他の回答 (1 件)

ghomer
ghomer 2023 年 7 月 17 日
Comment additionner deux signaux sinusoïdaux en MATLAB

カテゴリ

Help Center および File ExchangeDenoising and Compression についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by