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
댓글 수: 0
채택된 답변
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
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Title에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!