Multiplication of envelope function to that of sine wave

5 vues (au cours des 30 derniers jours)
Aishwarya Bannai
Aishwarya Bannai le 12 Mai 2021
Hello,
I am trying to multiply a base sine wave to that of a square wave and this square wave should act as an switch i,e if there is amplitude 1 then the sine should be present else 0,
t = 0:1e-4:0.1;
x = (1+square(4*pi*50*t)).*sin(2*pi*1000*t); %carrier frequency is 1khz and modulation frequency is 50hz
plot(t,x)
my question is I want different duration for both square function which is acting as an envelope and sine function which is the base and should be modified according to the envelope, but when I try to do it with two different durations it is giving me a matrix mismatch.
t = 0:1e-4:0.1;
ts = 0:1e-4:0.4
T = [t ts]
x = (1+square(4*pi*50*t).*sin(2*pi*1000*ts); %carrier frequency is 1khz and modulation frequency is 50hz
plot(T,x)
Thank you.

Réponse acceptée

Star Strider
Star Strider le 12 Mai 2021
I would just use the same value (either ‘t’ or ‘ts’) for both —
t = 0:1e-4:0.1;
ts = 0:1e-4:0.4;
T = [t ts];
x = (1+square(4*pi*50*t).*sin(2*pi*1000*t)); %carrier frequency is 1khz and modulation frequency is 50hz
figure
plot(t,x)
xlim([0 0.02]) % Zoom For Detail (Optional)
It would be possible to use both, however it would then be necessary to create a matrix of them, and that could be difficult to represent, for example —
x = (1+square(4*pi*50*t.')*sin(2*pi*1000*ts)); %carrier frequency is 1khz and modulation frequency is 50hz
figure
surf(ts, t, x)
grid on
xlabel('ts')
ylabel('t')
axis([0 0.025 0 0.00025 zlim]) % Zoom For Detail (Optional)
figure
surf(ts, t, x, 'EdgeColor','none')
grid on
xlabel('ts')
ylabel('t')
.

Plus de réponses (0)

Catégories

En savoir plus sur Visualization and Data Export 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