O‘ZBEKISTON RESPUBLIKASI AXBOROT TEXNOLOGIYALARI VA
KOMMUNIKATSIYALARINI RIVOJLANTIRISH VAZIRLIGI
MUHAMMAD AL-XORAZMIY NOMIDAGI
TOSHKENT AXBOROT TEXNOLOGIYALARI UNIVERSITETI
Signallar va tizimlar
Amaliy ish
Bajardi : Ergashev Dilshod
Tekshirdi: Nurmurodov Javohir
Matlab muhitida random usulida bajarilgani
x = [1 3 2 4 5 6 7 2 6 5 4 1 ];
h = fliplr(x);
zeros_before = 8; zeros_after = 10;
random_signal = [(10 * rand(1,zeros_before) - 5) x (10 * rand(1,zeros_after) - 5)];
noisy_signal = random_signal + (8 * rand(1,length(random_signal)) - 4);
stem(noisy_signal, 'LineWidth',2);
hold on;
stem([zeros(1,zeros_before) x zeros(1,zeros_after)], 'LineWidth', 2);
hold off; grid on;
expected_num = zeros_before + length(x)
ipython dasturida
import numpy as np
import matplotlib.pyplot as plt
from scipy import signal
def interpolate_hard(time, samples, numValuesToInsert = 3):
samplingPeriod = time[1] - time[0]
N = samples.size
iTime = np.linspace(time[0], time[-1], time.size * (numValuesToInsert + 1) - numValuesToInsert)
iSamples = np.empty(samples.size * (numValuesToInsert + 1) - numValuesToInsert)
iSamplingPeriod = iTime[1] - iTime[0]
for j in range(iSamples.size):
summ = 0
for i in range(0, N):
summ += samples[i] * np.sinc((j * iSamplingPeriod - i*samplingPeriod) / samplingPeriod)
iSamples[j] = summ
return iTime, iSamples
samples = np.array([1, 3, 2 ,4, 5, 6, 7, 2, 6, 5, 4, 1])
sampleRate = 1e6
sampleTime = np.arange(samples.size) / sampleRate
iTime, iSamples = interpolate_hard(sampleTime, samples)
plt.plot(sampleTime, samples, label = 'Samples')
plt.plot(iTime, iSamples, label = 'Interpolated')
plt.legend()
plt.show()
Dostları ilə paylaş: |