Multiplication of two different continuous signal in Matlab

30 visualizaciones (últimos 30 días)
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

Respuesta aceptada

Stephan
Stephan el 12 de Mayo de 2021
Editada: Stephan el 12 de Mayo de 2021
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])

Más respuestas (1)

ghomer
ghomer el 17 de Jul. de 2023
Comment additionner deux signaux sinusoïdaux en MATLAB

Categorías

Más información sobre Denoising and Compression en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by