ํ•„ํ„ฐ ์ง€์šฐ๊ธฐ
ํ•„ํ„ฐ ์ง€์šฐ๊ธฐ

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

์กฐํšŒ ์ˆ˜: 2 (์ตœ๊ทผ 30์ผ)
Patrick Westmoreland
Patrick Westmoreland 2023๋…„ 10์›” 23์ผ
์ด๋™: Walter Roberson 2023๋…„ 10์›” 24์ผ
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=109โ‹…2๐œ‹๐š›๐šŠ๐š/๐šœ, 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
John D'Errico
John D'Errico 2023๋…„ 10์›” 23์ผ
You did take an absolute value in there. I wonder if that precludes negative values?
Patrick Westmoreland
Patrick Westmoreland 2023๋…„ 10์›” 24์ผ
I meant that I got no negative values of the sinusoid and pulse width modulation product signal(first image). Not the fourier transform portion.

๋Œ“๊ธ€์„ ๋‹ฌ๋ ค๋ฉด ๋กœ๊ทธ์ธํ•˜์‹ญ์‹œ์˜ค.

์ฑ„ํƒ๋œ ๋‹ต๋ณ€

Walter Roberson
Walter Roberson 2023๋…„ 10์›” 24์ผ
์ด๋™: Walter Roberson 2023๋…„ 10์›” 24์ผ
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');

์ถ”๊ฐ€ ๋‹ต๋ณ€ (0๊ฐœ)

์นดํ…Œ๊ณ ๋ฆฌ

Help Center ๋ฐ File Exchange์—์„œ Waveform Generation์— ๋Œ€ํ•ด ์ž์„ธํžˆ ์•Œ์•„๋ณด๊ธฐ

ํƒœ๊ทธ

์ œํ’ˆ


๋ฆด๋ฆฌ์Šค

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by