Question in continuous time signals

4 views (last 30 days)
Fotis Val
Fotis Val on 25 Nov 2021
Answered: VBBV on 25 Nov 2021
I'm not sure about the represantation of a continuous time signal. Am I doing something wrong?
%%
DT = 0.01;
t = [-2:DT:12];
%% Question 2.1
%Parts of Signal
t1 = -2:DT:7;
y1_1 = (exp(abs(-0.5*t1))).*(2*sin(10*pi*t1)+cos(1*pi*t1));
t2 = 8:DT:12;
y1_2 = (0.75).^abs(-t2+10);
% Final Signal
%t = [t1 t2];
y1 = [y1_1 y1_2];
%% Question 2.2
%Parts of Signal
t1 = -2:DT:7;
y2_1 = (exp(abs(-0.5*(-t1-2)))).*(2*sin(10*pi*(-t1-2)))+cos(1*pi*(-t1-2));
t2 = 8:DT:12;
y2_2 = (0.75).^abs(t2+12);
% Final Signal
t = [t3 t4];
y2 = [y2_1 y2_2];
%% Conv Function
tconv = (t(1) +t(1):DT:t(end)+t(end));
F1 = conv(y1,y2)*DT;
stem(tconv,F1);

Answers (3)

Image Analyst
Image Analyst on 25 Nov 2021
Why are you going from 8 to 12 instead of (7+DT) to 12?

Star Strider
Star Strider on 25 Nov 2021
Everything in a computer are discrete, not continuous (except the voltages on the chips themselves and the outputs of a soundcard or similar DAC transducers). So ‘continuous’ signals otherwise only exist in symbolic variables, not numeric arrays or vectors, since by definition those are all sampled.
The posted code is doing everything it should (or could) to represent the signal vectors correctly (although some variables appear to be missing).
%%
DT = 0.01;
t = [-2:DT:12];
%% Question 2.1
%Parts of Signal
t1 = -2:DT:7;
y1_1 = (exp(abs(-0.5*t1))).*(2*sin(10*pi*t1)+cos(1*pi*t1));
t2 = 8:DT:12;
y1_2 = (0.75).^abs(-t2+10);
% Final Signal
%t = [t1 t2];
y1 = [y1_1 y1_2];
figure % Added
plot([t1 t2], y1) % Added
grid % Added
%% Question 2.2
%Parts of Signal
t1 = -2:DT:7;
y2_1 = (exp(abs(-0.5*(-t1-2)))).*(2*sin(10*pi*(-t1-2)))+cos(1*pi*(-t1-2));
t2 = 8:DT:12;
y2_2 = (0.75).^abs(t2+12);
% Final Signal
t = [t3 t4];
Unrecognized function or variable 't3'.
y2 = [y2_1 y2_2];
%% Conv Function
tconv = (t(1) +t(1):DT:t(end)+t(end));
F1 = conv(y1,y2)*DT;
stem(tconv,F1);
.

VBBV
VBBV on 25 Nov 2021
DT = 0.01;
t = [-2:DT:12];
%%Question 2.1
%Parts of Signal
t1 = -2:DT:7;
y1_1 = (exp(abs(-0.5*t1))).*(2*sin(10*pi*t1)+cos(1*pi*t1));
t2 = 8:DT:12;
y1_2 = (0.75).^abs(-t2+10);
% Final Signal
%t = [t1 t2];
y1 = [y1_1 y1_2];
%%Question 2.2
%Parts of Signal
t1 = -2:DT:7;
y2_1 = (exp(abs(-0.5*(-t1-2)))).*(2*sin(10*pi*(-t1-2)))+cos(1*pi*(-t1-2));
t2 = 8:DT:12;
y2_2 = (0.75).^abs(t2+12);
% Final Signal
t = [t1 t2];
y2 = [y2_1 y2_2];
%%Conv Function
tconv = (t(1) +t(1):DT:t(end)+t(end));
F1 = conv(y1,y2)*DT;
stem(F1);
figure(2);
plot(t,y1,t,y2)
The variables t3 and t4 are same as t1 and t2. So your discrete and continuous signal representations do match well.

Community Treasure Hunt

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

Start Hunting!