I want to change my code to a code like the one in the picture below, but how can I modify it?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
EonYak Kang
el 26 de Abr. de 2022
Comentada: EonYak Kang
el 26 de Abr. de 2022
clc
close all
dt = 1e-4;
Fs = 1/dt;
t=0:dt:0.5;
f=5;
y=sin(2*pi*f*t);
subplot(3,1,1)
plot(t,y)
hold on
yline(0)
xline(0.2)
ylim([-2 2])
hold off
subplot(3,1,2)
y1=sin(2*pi*100*t);
y3=y1.*y;
plot(t,y3)
hold on
yline(0)
hold off
subplot(3,1,3)
y4=y3.*sin(2*pi*100*t);
% y5=lowpass(y4,1,1e4)
[BlpFilt,AlpFilt] = butter(4,0.01);
% y5 =filter(BlpFilt,AlpFilt,y4);
y5 =filtfilt(BlpFilt,AlpFilt,y4);
plot(t,2*y5,'-*r')
hold on
ylim([-2 2])
plot(t,y);
hold off
2 comentarios
Rik
el 26 de Abr. de 2022
I suspect it will be much easier to plot the sinusoid and the envelope as separate line objects.
Respuesta aceptada
Jonas
el 26 de Abr. de 2022
Editada: Jonas
el 26 de Abr. de 2022
are you searching for something like that:
close all;
fs=4000;
t=0:1/fs:0.8;
myData=[0 3;
0.2 -2;
0.4 -1;
0.6 -2;
0.8 3]; % x y
myData=interp1(myData(:,1),myData(:,2),t,'pchip');
subplot(3,1,1);
plot(t,myData)
yline(0);
modulated = ammod(myData,100,fs);
% or modulated=sin(2*pi*100*t).*myData; % if you don't have the toolbox
subplot(3,1,2);
plot(t,modulated)
subplot(3,1,3)
plot(t,0.5*modulated+0.5*myData)
Más respuestas (1)
Sam Chak
el 26 de Abr. de 2022
Hi @EonYak Kang
Looks like a signal modulation problem in Communications Engineering.
If my guess is correct, then is the Modulator and is the Carrier signal.
You must have some knowledge in the mathematics of signal processing in order to "guess" the shape of the modulator.
Try adjusting the angular frequency yourself. The basic shape is shown below:
t = linspace(0, 2*pi, 2001);
m1 = 0.35*cos(2*pi*t/2);
m2 = cos(2*pi*t/6);
m = m1 + m2;
plot(t, m1, t, m2)
hold on
plot(t, m, 'linewidth', 2)
hold off
If there is no change in the carrier signal, I think you can complete the rest just like @Jonas has demonstrated.
Ver también
Categorías
Más información sobre Matched Filter and Ambiguity Function 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!