Multiplication of two different continuous signal in Matlab

32 visualizzazioni (ultimi 30 giorni)
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

Risposta accettata

Stephan
Stephan il 12 Mag 2021
Modificato: Stephan il 12 Mag 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])

Più risposte (1)

ghomer
ghomer il 17 Lug 2023
Comment additionner deux signaux sinusoïdaux en MATLAB

Categorie

Scopri di più su Denoising and Compression in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by