Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- clear all;
- load("lab2_coeff.mat");
- MX = 3; %Constant value
- SIGMAX = 0.5; %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 = ansambles(1, :).^2;
- c0 = ansambles(1, :).^2;
- 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)));
- %автокорреляция
- 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);
- %hist(c0);
- hold on;
- est_pdf = counts / sum(counts * mean(diff(bins)));
- pd = fitdist(c0','normal');
- x_pdf = linspace(min(c0),max(c0),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("Усредненная СПМ после квадратичного преобразователя");
- %end
Advertisement
Add Comment
Please, Sign In to add comment