how can i remove the dc componente from the output of the signal from workspace?
3 views (last 30 days)
Show older comments
clc; clear; close all;
stringa = '$GPGGA,123456.00,4807.038,N,01131.000,E,1,08,0.9,545.4,M,46.9,M,,*47';
% Inizializza il vettore per la trasmissione seriale in formato 8N1
trama_gps = [];
for i = 1:length(stringa)
binaryChar = dec2bin(stringa(i), 8) - '0'; % Converte il carattere in binario (8 bit)
% Formato 8N1: 1 bit di start (0), 8 bit di dati, 1 bit di stop (1)
transmittedChar = [0, binaryChar, 1];
% Aggiunge al vettore di trasmissione
trama_gps = [trama_gps, transmittedChar];
end
% Trasforma trama_gps in un vettore colonna
trama_gps_column = trama_gps(:); % Il simbolo ": " trasforma in una colonna
% Dividi i dati in coppie di bit
% Ogni coppia di bit sarà un elemento della matrice finale
num_pairs = length(trama_gps_column) / 2; % Numero di coppie di bit
% Prepara una matrice colonna per contenere le coppie di bit
qpsk_input = zeros(num_pairs, 1);
for i = 1:num_pairs
% Ogni elemento della matrice è una coppia di bit
bit_pair = trama_gps_column(2*i-1:2*i);
% Converti la coppia di bit in un numero binario
qpsk_input(i) = bi2de(bit_pair', 'left-msb'); % Converti la coppia di bit in un numero decimale
end
% Visualizza la matrice finale
disp('Input per QPSK (in formato colonna):');
disp(qpsk_input);
bit_rate = 2720;
% Visualizza la trama
disp('Trama GPS (8N1):');
fprintf('%d', trama_gps);
fprintf('\n');
% SF = 25735;
% n = SF * length(trama_gps); % Lunghezza del vettore
% prc_1 = randi([0, 1], 1, n);
This is my code. I m trying to use the spectrum analyzer in simulink to see the spectrum of qpsk_input. I want to put qpsk input in the qpsk modulator baseband (that s why qpsk_input ha integer). The problem is that at frequency 0Hz i have i dc component that i don t want? can someone help me to remove this DC component please?
0 Comments
Answers (1)
Aastha
on 24 Mar 2025
As I understand you want to remove the DC component of the signal in Simulink. There are two methods to do this.
Method1: Mean Subtraction
You may implement this method using a “MATLAB function” block in Simulink.
For more information on “MATLAB function” block, kindly refer to the documentation link mentioned below:
The DC component is the mean of the input signal. Since the Fourier transform is a linear operation, subtracting the mean of the input signal will remove the DC component of the signal. You can do this using the following MATLAB code snippet:
qpsk_input = qpsk_input - mean(qpsk_input);
Method 2: High Pass Filtering
To remove the DC component, you can use a high pass filter. This will give you more control over the frequencies that are suppressed. To do this you can use the “Highpass Filter” block in Simulink. You can set the parameters of the “Highpass Filter” block according to the requirements to perform filtering of the DC component.
You can find more information about the the “Highpass Filter” block in Simulink in the documentation link mentioned below:
Hope this helps!
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!