generating noisy data to play with in DSP
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hello,is there a way in matlab to create a signal put a high frequency noise on it and take samples from it to play with DSP FIR filter later.
Like the example samples showsn bellow.
Is there a tool in matlab that can generate such a thing?
Thanks.
// Test data of a 10kHz cosine wave
float32_t testData[128] =
{
0,9.6592579,5,-7.0710678,-8.6602535,2.5881906,10,2.5881906,-8.6602535,
-7.0710678,5,9.6592579,6.1232342e-15,-9.6592579,-5,7.0710678,8.6602535,
-2.5881906,-10,-2.5881906,8.6602535,7.0710678,-5,-9.6592579,-1.2246468e-14,
9.6592579,5,-7.0710678,-8.6602535,2.5881906,10,2.5881906,-8.6602535,
-7.0710678,5,9.6592579,-1.7157435e-14,-9.6592579,-5,7.0710678,8.6602535,
-2.5881906,-10,-2.5881906,8.6602535,7.0710678,-5,-9.6592579,-2.4492937e-14,
9.6592579,5,-7.0710678,-8.6602535,2.5881906,10,2.5881906,-8.6602535,
-7.0710678,5,9.6592579,-4.9109666e-15,-9.6592579,-5,7.0710678,8.6602535,
-2.5881906,-10,-2.5881906,8.6602535,7.0710678,-5,-9.6592579,3.4314870e-14,
9.6592579,5,-7.0710678,-8.6602535,2.5881906,10,2.5881906,-8.6602535,
-7.0710678,5,9.6592579,-6.3718772e-14,-9.6592579,-5,7.0710678,8.6602535,
-2.5881906,-10,-2.5881906,8.6602535,7.0710678,-5,-9.6592579,-4.8985874e-14,
9.6592579,5,-7.0710678,-8.6602535,2.5881906,10,2.5881906,-8.6602535,
-7.0710678,5,9.6592579,-2.6463513e-13,-9.6592579,-5,7.0710678,8.6602535,
-2.5881906,-10,-2.5881906,8.6602535,7.0710678,-5,-9.6592579,9.8219332e-15,
9.6592579,5,-7.0710678,-8.6602535,2.5881906,10,2.5881906
};
0 Commenti
Risposte (1)
Omega
il 2 Ago 2024
Hi Fima,
Yes, MATLAB has several tools and functions that can help you generate a signal, add high-frequency noise, and take samples for DSP (Digital Signal Processing) applications. Below is an example of how you can generate a 10 kHz cosine wave, add high-frequency noise to it, and then take samples from it. You can adjust the parameters and the downsample factor as needed for your specific application.
% Parameters
Fs = 100e3; % Sampling frequency (100 kHz)
duration = 0.01; % Duration of the signal (10 ms)
t = 0:1/Fs:duration-1/Fs; % Time vector of 10 ms
f = 10e3; % Frequency of the cosine wave (10 kHz)
f_noise = 50e3; % Frequency of the noise (50 kHz)
noise_amplitude = 1; % Amplitude of the noise
% Generate the 10 kHz cosine wave
signal = cos(2*pi*f*t);
% Generate high-frequency noise
noise = noise_amplitude * cos(2*pi*f_noise*t);
% Add noise to the signal
noisy_signal = signal + noise;
% Plot the signals
figure;
subplot(3,1,1);
plot(t, signal);
title('Original 10 kHz Cosine Wave');
xlabel('Time (s)');
ylabel('Amplitude');
subplot(3,1,2);
plot(t, noise);
title('High-Frequency Noise (50 kHz)');
xlabel('Time (s)');
ylabel('Amplitude');
subplot(3,1,3);
plot(t, noisy_signal);
title('Noisy Signal');
xlabel('Time (s)');
ylabel('Amplitude');
% Downsample the signal using resample (e.g., by a factor of 10)
downsample_factor = 10;
downsampled_signal = resample(noisy_signal, 1, downsample_factor);
downsampled_time = linspace(0, duration, length(downsampled_signal));
% Plot the downsampled signal
figure;
plot(downsampled_time, downsampled_signal, '-o');
title('Downsampled Noisy Signal');
xlabel('Time (s)');
ylabel('Amplitude');
% Save downsampled signal to a variable (e.g., for later use in FIR filtering)
testData = downsampled_signal;
% Display the first few samples
disp('First few samples of the downsampled noisy signal:');
disp(testData(1:10));
0 Commenti
Vedere anche
Categorie
Scopri di più su Get Started with DSP System Toolbox in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!