randomly data distribution with specific distribution

1 次查看(过去 30 天)
I want to create a matrix A size(1*24) ,and matrix element should be within the range of 150-300, but the condition is that this matrix should be similar of matrix B=[2063 2003 1992 2004 2070 2246 2678 3083 3161 3160 3176 3130 3038 3047 2985 2930 3069 3229 3087 2929 2790 2602 2404 2205] that both matrices A and B peak/low value should be at same position and other data are also in same distribution. thanks

采纳的回答

Pawel Jastrzebski
Pawel Jastrzebski 2018-3-23
This should get you close enough:
% Based on:
% https://stackoverflow.com/questions/10364575/normalization-in-variable-range-x-y-in-matlab
B=[2063 2003 1992 2004 2070 2246 2678 3083 3161 3160 3176 3130 3038 3047 2985 2930 3069 3229 3087 2929 2790 2602 2404 2205];
Bmin = min(B)
Bmax = max(B)
Brange = Bmax - Bmin
figure
subplot(2,2,1)
plot(1:length(B),B,'o--r')
title('Original data')
% Normalize to [0, 1]
Bnorm = (B - Bmin)./Brange
subplot(2,2,2)
plot(1:length(B),Bnorm,'o--b')
title('Normalised to [0 1]')
% Scale up to new range [newMIN, newMAX]
newMIN = 150;
newMAX = 300;
newRange = newMAX - newMIN
Bnew = (Bnorm*newRange)+newMIN
% add some noise
noise = rand(size(Bnew));
subplot(2,2,[3,4])
plot(1:length(B),Bnew,'o--g')
hold on
plot(1:length(B),Bnew+noise,'.k')
title('Normalised to [150 300] + noise')
Outcome:

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Title 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by