# Multiplication of envelope function to that of sine wave

조회 수: 3(최근 30일)
Aishwarya Bannai 2021년 5월 12일
답변: Star Strider 2021년 5월 12일
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.

댓글을 달려면 로그인하십시오.

### 채택된 답변

Star Strider 2021년 5월 12일
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')
.

댓글을 달려면 로그인하십시오.

### Community Treasure Hunt

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

Start Hunting!

Translated by