randomly data distribution with specific distribution
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
mukesh kumar
il 23 Mar 2018
Risposto: Pawel Jastrzebski
il 23 Mar 2018
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 Commenti
Risposta accettata
Pawel Jastrzebski
il 23 Mar 2018
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 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Title in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!