Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- clear all;
- load("lab2_coeff.mat");
- MX = 0; %Constant value
- SIGMAX = 0.3; %Mean square deviations
- N = 10000; %Count samples
- K = 100;%Count realizations of process
- fs = 1000; %Freuency of sampling
- amp = 10;
- ansambles = zeros(K, N);
- %TODO norming Fsampling with time value
- x = normrnd(MX, SIGMAX, 1, N);
- %Generate random process
- for i = 1:K
- ansambles(i, :) =amp * normrnd(MX, SIGMAX, 1, N);
- end
- norm_time = zeros(1, N);
- %Math time norming
- for i = 1:N
- norm_time(i) = i/fs;
- end
- %Plot graph
- %for i = 1: K
- %Create array after circuits
- c0 = filter([1, -0.5], 1, ansambles(1, :));
- c1 = filter([1, 0.5], 1, ansambles(1, :));
- %part2 of circuits
- c2 = filter(1, [1, +0.9], ansambles(1, :));
- c3 = filter(1, [1, -0.9], ansambles(1, :));
- c4 = filter(Num, 1, ansambles(1, :));
- i = 1;
- figure
- plot(norm_time, ansambles(i, :));
- hold on
- title("Реализация случайного процесса");
- xlabel("t, s");
- ylabel("x(t), V");
- plot(norm_time, mean(ansambles(i, :)) * ones(size(norm_time)));
- plot(norm_time, std(ansambles(i, :)) * ones(size(norm_time)));
- plot(norm_time, std(ansambles(i, :)) * -1 * ones(size(norm_time)));
- plot(norm_time, var(ansambles(i, :)) * ones(size(norm_time)));
- plot(norm_time, var(ansambles(i, :)) * -1 * ones(size(norm_time)));
- grid on;
- %%end
- %c0
- figure
- plot(norm_time, c0);
- hold on
- title("Реализация случайного процесса после прохождения цепи");
- xlabel("t, s");
- ylabel("x(t), V");
- plot(norm_time, mean(c0) * ones(size(norm_time)));
- plot(norm_time, std(c0) * ones(size(norm_time)));
- plot(norm_time, std(c0) * -1 * ones(size(norm_time)));
- plot(norm_time, var(c0) * ones(size(norm_time)));
- plot(norm_time, var(c0) * -1 * ones(size(norm_time)));
- %c1
- figure
- plot(norm_time, c1);
- hold on
- title("Реализация случайного процесса после прохождения цепи");
- xlabel("t, s");
- ylabel("x(t), V");
- plot(norm_time, mean(c1) * ones(size(norm_time)));
- plot(norm_time, std(c1) * ones(size(norm_time)));
- plot(norm_time, std(c1) * -1 * ones(size(norm_time)));
- plot(norm_time, var(c1) * ones(size(norm_time)));
- plot(norm_time, var(c1) * -1 * ones(size(norm_time)));
- %c2
- figure
- plot(norm_time, c2);
- hold on
- title("Реализация случайного процесса после прохождения цепи");
- xlabel("t, s");
- ylabel("x(t), V");
- plot(norm_time, mean(c2) * ones(size(norm_time)));
- plot(norm_time, std(c2) * ones(size(norm_time)));
- plot(norm_time, std(c2) * -1 * ones(size(norm_time)));
- plot(norm_time, var(c2) * ones(size(norm_time)));
- plot(norm_time, var(c2) * -1 * ones(size(norm_time)));
- %c3
- figure
- plot(norm_time, c3);
- hold on
- title("Реализация случайного процесса после прохождения цепи");
- xlabel("t, s");
- ylabel("x(t), V");
- plot(norm_time, mean(c3) * ones(size(norm_time)));
- plot(norm_time, std(c3) * ones(size(norm_time)));
- plot(norm_time, std(c3) * -1 * ones(size(norm_time)));
- plot(norm_time, var(c3) * ones(size(norm_time)));
- plot(norm_time, var(c3) * -1 * ones(size(norm_time)));
- %c4
- figure
- plot(norm_time, c4);
- hold on
- title("Реализация случайного процесса после прохождения цепи");
- xlabel("t, s");
- ylabel("x(t), V");
- plot(norm_time, mean(c4) * ones(size(norm_time)));
- plot(norm_time, std(c4) * ones(size(norm_time)));
- plot(norm_time, std(c4) * -1 * ones(size(norm_time)));
- plot(norm_time, var(c4) * ones(size(norm_time)));
- plot(norm_time, var(c4) * -1 * ones(size(norm_time)));
- %автокорреляция
- figure
- plot(xcorr(ansambles(1, :)));
- title("Автокорреляция");
- i = 1;
- figure
- [counts, bins] = hist(ansambles(i, :));
- hold on;
- est_pdf = counts / sum(counts * mean(diff(bins)));
- pd = fitdist(ansambles(1, :)','normal');
- x_pdf = linspace(min(ansambles(i, :)),max(ansambles(i, :)),length(norm_time));
- y_pdf = pdf(pd,x_pdf);
- bar(bins,est_pdf);
- plot(x_pdf, y_pdf, '-r');
- title("плотность вероятности и ее оценка");
- %c0
- figure
- plot(xcorr(c0));
- title("Автокорреляция");
- i = 1;
- figure
- [counts, bins] = hist(c0);
- hold on;
- est_pdf = counts / sum(counts * mean(diff(bins)));
- pd = fitdist(ansambles(1, :)','normal');
- x_pdf = linspace(min(ansambles(i, :)),max(ansambles(i, :)),length(norm_time));
- y_pdf = pdf(pd,x_pdf);
- bar(bins,est_pdf);
- plot(x_pdf, y_pdf, '-r');
- title("плотность вероятности и ее оценка");
- %c1
- figure
- plot(xcorr(c1));
- title("Автокорреляция");
- i = 1;
- figure
- [counts, bins] = hist(c1);
- hold on;
- est_pdf = counts / sum(counts * mean(diff(bins)));
- pd = fitdist(ansambles(1, :)','normal');
- x_pdf = linspace(min(ansambles(i, :)),max(ansambles(i, :)),length(norm_time));
- y_pdf = pdf(pd,x_pdf);
- bar(bins,est_pdf);
- plot(x_pdf, y_pdf, '-r');
- title("плотность вероятности и ее оценка");
- %c2
- figure
- plot(xcorr(c2));
- title("Автокорреляция");
- i = 1;
- figure
- [counts, bins] = hist(c2);
- hold on;
- est_pdf = counts / sum(counts * mean(diff(bins)));
- pd = fitdist(ansambles(1, :)','normal');
- x_pdf = linspace(min(ansambles(i, :)),max(ansambles(i, :)),length(norm_time));
- y_pdf = pdf(pd,x_pdf);
- bar(bins,est_pdf);
- plot(x_pdf, y_pdf, '-r');
- title("плотность вероятности и ее оценка");
- %c3
- figure
- plot(xcorr(c3));
- title("Автокорреляция");
- i = 1;
- figure
- [counts, bins] = hist(c3);
- hold on;
- est_pdf = counts / sum(counts * mean(diff(bins)));
- pd = fitdist(ansambles(1, :)','normal');
- x_pdf = linspace(min(ansambles(i, :)),max(ansambles(i, :)),length(norm_time));
- y_pdf = pdf(pd,x_pdf);
- bar(bins,est_pdf);
- plot(x_pdf, y_pdf, '-r');
- title("плотность вероятности и ее оценка");
- %c4
- figure
- plot(xcorr(c4));
- title("Автокорреляция для фильтра");
- i = 1;
- figure
- [counts, bins] = hist(c4);
- hold on;
- est_pdf = counts / sum(counts * mean(diff(bins)));
- pd = fitdist(ansambles(1, :)','normal');
- x_pdf = linspace(min(ansambles(i, :)),max(ansambles(i, :)),length(norm_time));
- y_pdf = pdf(pd,x_pdf);
- bar(bins,est_pdf);
- plot(x_pdf, y_pdf, '-r');
- title("плотность вероятности и ее оценка для фильтра");
- %
- figure
- hold on
- cdfplot(ansambles(i, :))
- histogram(ansambles(1, :), 'Normalization', 'cdf');
- title("Функция распределения и ее оценка");
- figure
- %PSD = periodogram(ansambles(1, :), [], length(ansambles(1, :)), fs, 'centered');
- PSD = 10 * log10(abs(fft(ansambles(1, :))).^2/N/fs);
- %PSD = fftshift(PSD);
- plot(PSD);
- title("СПМ");
- ans_mean = zeros(1, length(ansambles(1, :)));
- for i = 1: K
- ans_mean(1, :) = ans_mean(1, :) + ansambles(i, :);
- end
- ans_mean = ans_mean / K;
- figure
- PSD_M= 10 * log10(abs(fft(ans_mean(1, :))).^2/N/fs);
- plot(PSD_M);
- hold on;
- title("Усредненная СПМ");
- %end
- %с0
- figure
- hold on
- cdfplot(c0)
- histogram(c0, 'Normalization', 'cdf');
- title("Функция распределения и ее оценка");
- figure
- %PSD = periodogram(ansambles(1, :), [], length(ansambles(1, :)), fs, 'centered');
- PSD = 10 * log10(abs(fft(c0)).^2/N/fs);
- %PSD = fftshift(PSD);
- plot(PSD);
- title("СПМ");
- ans_mean = zeros(1, length(c0));
- for i = 1: K
- ans_mean(1, :) = ans_mean(1, :) + c0;
- end
- ans_mean = ans_mean / K;
- figure
- PSD_M= 10 * log10(abs(fft(ans_mean(1, :))).^2/N/fs);
- plot(PSD_M);
- hold on;
- title("Усредненная СПМ");
- %c1
- figure
- hold on
- cdfplot(c1)
- histogram(c1, 'Normalization', 'cdf');
- title("Функция распределения и ее оценка");
- figure
- %PSD = periodogram(ansambles(1, :), [], length(ansambles(1, :)), fs, 'centered');
- PSD = 10 * log10(abs(fft(c1)).^2/N/fs);
- %PSD = fftshift(PSD);
- plot(PSD);
- title("СПМ");
- ans_mean = zeros(1, length(c1));
- for i = 1: K
- ans_mean(1, :) = ans_mean(1, :) + c1;
- end
- ans_mean = ans_mean / K;
- figure
- PSD_M= 10 * log10(abs(fft(ans_mean(1, :))).^2/N/fs);
- plot(PSD_M);
- hold on;
- title("Усредненная СПМ");
- %c2
- figure
- hold on
- cdfplot(c2)
- histogram(c2, 'Normalization', 'cdf');
- title("Функция распределения и ее оценка");
- figure
- %PSD = periodogram(ansambles(1, :), [], length(ansambles(1, :)), fs, 'centered');
- PSD = 10 * log10(abs(fft(c2)).^2/N/fs);
- %PSD = fftshift(PSD);
- plot(PSD);
- title("СПМ");
- ans_mean = zeros(1, length(c2));
- for i = 1: K
- ans_mean(1, :) = ans_mean(1, :) + c2;
- end
- ans_mean = ans_mean / K;
- figure
- PSD_M= 10 * log10(abs(fft(ans_mean(1, :))).^2/N/fs);
- plot(PSD_M);
- hold on;
- title("Усредненная СПМ");
- %c3
- figure
- hold on
- cdfplot(c3)
- histogram(c3, 'Normalization', 'cdf');
- title("Функция распределения и ее оценка");
- figure
- %PSD = periodogram(ansambles(1, :), [], length(ansambles(1, :)), fs, 'centered');
- PSD = 10 * log10(abs(fft(c3)).^2/N/fs);
- %PSD = fftshift(PSD);
- plot(PSD);
- title("СПМ");
- ans_mean = zeros(1, length(c3));
- for i = 1: K
- ans_mean(1, :) = ans_mean(1, :) + c3;
- end
- ans_mean = ans_mean / K;
- figure
- PSD_M= 10 * log10(abs(fft(ans_mean(1, :))).^2/N/fs);
- plot(PSD_M);
- hold on;
- title("Усредненная СПМ");
- %c4
- figure
- hold on
- cdfplot(c4)
- histogram(c4, 'Normalization', 'cdf');
- title("Функция распределения и ее оценка");
- figure
- %PSD = periodogram(ansambles(1, :), [], length(ansambles(1, :)), fs, 'centered');
- PSD = 10 * log10(abs(fft(c4)).^2/N/fs);
- %PSD = fftshift(PSD);
- plot(PSD);
- title("СПМ");
- ans_mean = zeros(1, length(c4));
- for i = 1: K
- ans_mean(1, :) = ans_mean(1, :) + c4;
- end
- ans_mean = ans_mean / K;
- figure
- PSD_M= 10 * log10(abs(fft(ans_mean(1, :))).^2/N/fs);
- plot(PSD_M);
- hold on;
- title("Усредненная СПМ");
- %end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement