Azzera filtri
Azzera filtri

Can anyone verify that my solution to the question below is correct?

2 visualizzazioni (ultimi 30 giorni)
I am not experienced at all with Matlab and I just wanted to verify that I am doing this correctly. The question is:
Consider the case of a sinusoidal signal whose amplitude is modulated by a train of pulses:
𝑆(𝑡)=sin(𝜔0𝑡)𝑃(𝑡)where 𝑃(𝑡) is a train of pulses with pulsed values of 0 and 1. Lets us set 𝜔0=1092𝜋𝚛𝚊𝚍/𝚜, and period of 𝑃(𝑡)=10^−6 seconds with a duty cycle 𝐷=10%.
Plot 𝑆(𝑡) as function of 𝑡 for at least 10𝚜
Plot the spectrum of P(t)
My solution to this is:
t = linspace(0,10e-6,1000);
x = 0.5*(square(2*pi*1000000.*t,10)+1); % change square wave to go from 0 to 1 vs -1 to 1
Amp = 1;
y = Amp * sin(2*pi*1e9.*t); %1 GHz signal
S = x.*y;
plot(t,S);
xlabel('time');
ylabel('product wave');
% plot frequency spectrum of input square wave
p1 = abs(fft(x));
plot(p1);
xlabel('freq');
ylabel('magnitude');
title('magnitude of frequency spectrum');
My plot for S(t) includes no negative values of the sinusoid so I am not sure if it is correct.
  2 Commenti
John D'Errico
John D'Errico il 23 Ott 2023
You did take an absolute value in there. I wonder if that precludes negative values?
Patrick Westmoreland
Patrick Westmoreland il 24 Ott 2023
I meant that I got no negative values of the sinusoid and pulse width modulation product signal(first image). Not the fourier transform portion.

Accedi per commentare.

Risposta accettata

Walter Roberson
Walter Roberson il 24 Ott 2023
Spostato: Walter Roberson il 24 Ott 2023
You have aliasing. You have a signal [0 10e-6] sampled 1000 points, so each is about 10e-9 apart.
Your y sine wave is frequency 2pi * 1e9 so each time sample in t is about 2pi * 10e-9 * 1e-9 = 2pi * 10 which is an integer multiple of pi and so sin() is the same for each of them.
Or that would be the case if they were exactly spaced 10e-9 apart. But you have a range that includes the endpoints and 1000 points, and to have it return to the endpoint on the 1000'th point the frequency has to be 1000/999 times higher than was discussed. If you adjust the linspace to use 1001 points instead of 1000 then you get the nice even spacing between the points and the other values become noise.
Remember, linspace includes the endpoints. linspace(0,1,4) is [0, 1/3, 2/3, 1] not [0, 1/4, 1/2, 3/4, 1]
t = linspace(0,10e-6,1001);
x = 0.5*(square(2*pi*1000000.*t,10)+1); % change square wave to go from 0 to 1 vs -1 to 1
plot(t, x)
Amp = 1;
y = Amp * sin(2*pi*1e9.*t); %1 GHz signal
plot(t, y)
S = x.*y;
plot(t,S);
xlabel('time');
ylabel('product wave');

Più risposte (0)

Tag

Prodotti


Release

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by