1
$\begingroup$

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:

$$S(t) = \sin(\omega_0 t)P(t)$$ where $P(t)$ is a train of pulses with pulsed values of $0$ and $1$. Lets us set $\omega_0 = 10^9 \cdot 2\pi \,\texttt{rad/s}$, and period of $P(t)=10^{-6} \,\texttt{s}$ with a duty cycle $D = 10 \%$.

Plot $S(t)$ as function of $t$ for at least $10 \,\texttt{s}$

The rest of the assignment deals with plotting spectrums but I need to make sure that the first portion is correct. 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');

I ended up getting a plot that had no negative samples of the sinusoid.

$\endgroup$
5
  • $\begingroup$ Hi Michael, I've edited your question for better formatting. Make sure everything looks right please. $\endgroup$
    – Jdip
    Oct 23, 2023 at 19:39
  • 1
    $\begingroup$ It seems that you're trying to plot $10^{10}$ periods of the sine wave -- are you sure you want to do that? $\endgroup$
    – MBaz
    Oct 23, 2023 at 21:11
  • $\begingroup$ Yes, the assignment specifically asks that we plot the product of the sine wave and the PWM signal for 10 microseconds, it just got edited out. $\endgroup$
    – Michael
    Oct 23, 2023 at 21:12
  • $\begingroup$ Also, the sampling frequency in your code is $10^5$. Does that agree with the sampling theorem? $\endgroup$
    – MBaz
    Oct 23, 2023 at 21:12
  • $\begingroup$ 10 microseconds is more reasonable, but still $10^4$ periods... $\endgroup$
    – MBaz
    Oct 23, 2023 at 21:15

1 Answer 1

2
$\begingroup$

Your values seem unreasonable to me. You want to generate a 1 gigahertz sine wave. If you want, say, ten samples per cycle then your signal sample rate must be Fs = 10 gigahertz. A ten second sequence whose sample rate is 10 gigahertz would be 100 gigasamples in length. Your computer doesn’t have enough memory to accommodate such lengthy sine wave sequence.

$\endgroup$
1
  • $\begingroup$ Oops, I got a number wrong. Your signal sample rate must be Fs = 10 gigahertz. A ten second sequence whose sample rate is 10 gigahertz would be 100 gigasamples in length. Your computer doesn’t have enough memory to accommodate such lengthy sine wave sequence. $\endgroup$ Oct 24, 2023 at 17:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.