How to control the variation speed of a generated random signal ?

조회 수: 5 (최근 30일)
youcha
youcha 2022년 5월 3일
편집: Jan 2022년 5월 4일
Hello:
I want to generate a random signal that 1) follows a Normal distribution 2) has slow variations. So I have did this:
pd_lp = makedist('Normal','mu',2,'sigma',1);
R_lp_base = random(pd_lp,5000,1);
figure
plot(R_lp_base)
The variation of this signal is rapid and I need it to be slow. Does anyone knows how to control the variation´s speed of the random generated signals in matlab ?
  댓글 수: 2
Jan
Jan 2022년 5월 3일
How slow is "slow"? Would this solve your needs:
x = sort(R_lp_base);
This is the slowest possible version.
youcha
youcha 2022년 5월 4일
Hello:
I want something similar to the effect of creating a signal with 50 points and then interpolate the signal to expand the points and get 5000 points.
The idea of interpolation is not correct for my case because it modify the statistical distribution of the original signal (R_lp_base is Gaussian but R_lp is not Gaussian)
pd_lp = makedist('Normal','mu',2,'sigma',1);
R_lp_base = random(pd_lp,50,1);
figure()
plot(R_lp_base)
R_lp=interp1(1:50,R_lp_base,linspace(1,50,5000)','spline');
figure
plot(R_lp)

댓글을 달려면 로그인하십시오.

답변 (1개)

Jan
Jan 2022년 5월 4일
편집: Jan 2022년 5월 4일
Start with sorting the random values. Then mix the result partially:
x = rand(1, 500);
y = sort(x);
z1 = [y(1:2:500), flip(y(2:2:500))];
z2 = [z1(1:2:500), flip(z1(2:2:500))];
t = 1:500;
plot(t, x, 'b', t, y+1.1, 'g', t, z1+2.2, 'c', t, z2+3.3, 'r')
This has the wanted distribution and you can increase the "speed" with applying [zi(1:2:500), flip(zi(2:2:500))] repeatedly.
Alternative:
x = rand(1, 500);
y = x;
s = 0.01;
for k = 2:500
match = find(abs(y(k:500) - y(k-1)) < s);
if ~isempty(match)
r = match(randi([1, numel(match)])) + k - 1;
[y(k), y(r)] = swap(y(k), y(r));
end
end
t = 1:500;
plot(t, x, 'b', t, y+1, 'c')
mean(abs(diff(x)))
ans = 0.3521
mean(abs(diff(y)))
ans = 0.0432
function [b,a] = swap(a,b)
end
What an ugly hack. Call it "mudsort".
  댓글 수: 1
youcha
youcha 2022년 5월 4일
I did not understand your code.
If you have ploted the code I added in the last comment you will be able to see the meaning of slow variation that I want.
My question is there anyway to adjust the argumento or the parameters of the makedist function to control the speed variation of the signal?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Pulse and Transition Metrics에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by