Multiplication of two different continuous signal in Matlab

30 vues (au cours des 30 derniers jours)
Aishwarya Bannai
Aishwarya Bannai le 12 Mai 2021
Réponse apportée : ghomer le 17 Juil 2023
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

Réponse acceptée

Stephan
Stephan le 12 Mai 2021
Modifié(e) : Stephan le 12 Mai 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])

Plus de réponses (1)

ghomer
ghomer le 17 Juil 2023
Comment additionner deux signaux sinusoïdaux en MATLAB

Catégories

En savoir plus sur Denoising and Compression dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by