Multiplication of two different continuous signal in Matlab

조회 수: 32 (최근 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개)

ghomer
ghomer 2023년 7월 17일
Comment additionner deux signaux sinusoïdaux en MATLAB

카테고리

Help CenterFile Exchange에서 Denoising and Compression에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by