Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tp-audio-ee-etudiant-c24leray
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
UEEE
sar-signal-audio
gr-vhdl-c24leray
tp-audio-ee-etudiant-c24leray
Commits
894a0440
Commit
894a0440
authored
1 month ago
by
LERAYS Camille
Browse files
Options
Downloads
Patches
Plain Diff
nsm
parent
878ee950
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
question_21.asv
+71
-0
71 additions, 0 deletions
question_21.asv
question_21.m
+62
-4
62 additions, 4 deletions
question_21.m
with
133 additions
and
4 deletions
question_21.asv
0 → 100644
+
71
−
0
View file @
894a0440
fs = 10e3; % Fréquence d'échantillonnage
T = 2*pi;
t = -1:1/fs:1; % Durée du signal
x_1 =square(2*pi*t/T);
%fft
X_1 = 10*log10(abs(fftshift(fft(x))));
N =length(t) ;
freq = (-N/2:N/2-1)*(1/(T*N));
figure;
stem(freq, X_1, '.') % Tracé du signal
xlabel('f (Hz)')
ylabel('10log(|X_1|)')
title('spectre du signal carré');
x_2 = sawtooth(2*pi*t/T);
plot(t,x_2)
title('sawtooth')
%fft
X_2 = 10*log10(abs(fftshift(fft(x_2))));
figure;
stem(freq, X_2, '.')
xlabel('f (Hz)')
ylabel('10log(|X_1|)')
title('spectre du signal en dent de scie');
%question 2.2------------------------------------------
% Paramètres
T = 2*pi;
N = 1000;
t = linspace(-T/2, T/2, N);
% Signal carré en entrée (amplitude ±1)
x = sign(sin(2*pi*t/T));
% Filtrage : y(k) = 1/2 (x(k) + x(k-1))
y = zeros(size(x));
y(2:end) = 0.5 * (x(2:end) + x(1:end-1));
% FFT
X = fftshift(fft(x))/N;
Y = fftshift(fft(y))/N;
f = (-N/2:N/2-1)*(1/(T/N)); % Axe fréquentiel
omega = 2*pi*f*(T/N); % Fréquence angulaire en rad/sample
% Réponse théorique du filtre
H = abs(cos(omega/2));
% Affichage
figure;
subplot(3,1,1);
plot(t, x); title('Signal d''entrée x(k)');
subplot(3,1,2);
plot(t, y); title('Signal filtré y(k)');
subplot(3,1,3);
plot(f, abs(Y), 'b', 'DisplayName', '|Y(f)|');
hold on;
plot(f, abs(X).*H, 'r--', 'DisplayName', '|X(f)| × |H(f)| (théorique)');
legend; xlabel('Fréquence (Hz)');
title('Spectre de sortie comparé à la théorie');
xlim([-10 10]);
This diff is collapsed.
Click to expand it.
question_21.m
+
62
−
4
View file @
894a0440
fs
=
10e3
;
% Fréquence d'échantillonnage
t = 0:1/fs:1.5; % Durée du signal
x = square(2*pi*50*t, 25); % Génération du signal carré avec un cycle de charge de 25%
plot(t, x) % Tracé du signal
axis([0 0.2 -1 1]) % Ajustement des limites de l'axe
\ No newline at end of file
T
=
1
/
10
;
t
=
-
1
:
1
/
fs
:
1
;
% Durée du signal
x_1
=
square
(
2
*
pi
*
t
/
T
);
%fft
X_1
=
10
*
log10
(
abs
(
fftshift
(
fft
(
x
))));
N
=
length
(
t
)
;
freq
=
(
-
N
/
2
:
N
/
2
-
1
)
*
(
1
/(
T
*
N
));
figure
;
stem
(
freq
,
X_1
,
'.'
)
% Tracé du signal
xlabel
(
'f (Hz)'
)
ylabel
(
'10log(|X_1|)'
)
title
(
'spectre du signal carré'
);
x_2
=
sawtooth
(
2
*
pi
*
t
/
T
);
plot
(
t
,
x_2
)
title
(
'sawtooth'
)
%fft
X_2
=
10
*
log10
(
abs
(
fftshift
(
fft
(
x_2
))));
figure
;
stem
(
freq
,
X_2
,
'.'
)
xlabel
(
'f (Hz)'
)
ylabel
(
'10log(|X_1|)'
)
title
(
'spectre du signal en dent de scie'
);
%question 2.2------------------------------------------
% Filtrage : y(k) = 1/2 (x(k) + x(k-1))
y
=
zeros
(
size
(
x_1
));
y
(
2
:
end
)
=
0.5
*
(
x_1
(
2
:
end
)
+
x_1
(
1
:
end
-
1
));
% FFT
X2
=
fftshift
(
fft
(
x_1
))/
N
;
Y
=
fftshift
(
fft
(
y
))/
N
;
f
=
(
-
N
/
2
:
N
/
2
-
1
)
*
(
1
/(
T
/
N
));
% Axe fréquentiel
omega
=
2
*
pi
*
f
*
(
T
/
N
);
% Fréquence angulaire en rad/sample
% Réponse théorique du filtre
H
=
abs
(
cos
(
omega
/
2
));
% Affichage
figure
;
subplot
(
3
,
1
,
1
);
plot
(
t
,
x_1
);
title
(
'Signal d
''
entrée x(k)'
);
subplot
(
3
,
1
,
2
);
plot
(
t
,
y
);
title
(
'Signal filtré y(k)'
);
subplot
(
3
,
1
,
3
);
plot
(
f
,
abs
(
Y
),
'b'
,
'DisplayName'
,
'|Y(f)|'
);
hold
on
;
plot
(
f
,
abs
(
X2
)
.*
H
,
'r'
,
'DisplayName'
,
'|X(f)| × |H(f)| (théorique)'
);
legend
;
xlabel
(
'Fréquence (Hz)'
);
title
(
'Spectre de sortie comparé à la théorie'
);
xlim
([
-
10
10
]);
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment