Define data list with a determine data distribution
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi all,
I would like to use a min data distribution in my code. For example: I define each data positions are 500 or more. So when the first point difference is less than 700 with the second point, the second point will be deleted and the third point become the second one and so on. The results that I want like this:
mindist = 700; %minimum treshold for Data1
Data1 = [67106; 67732; 117467; 118467; 118967];
Data2 = [759.6421; 23.3729; 232.5324; 23.3729; 231.5324];
And I want the results to become:
Data1 = [67106; 117467; 118467];
Data2 = [759.6421; 232.5324; 23.3729];
Thank you, hope to hear your reply soon
0 Kommentare
Antworten (1)
Joe Vinciguerra
am 29 Jun. 2023
% Generate some random data that's similar to yours
Data1 = sort(randi(1e4,[10,1])); % making sure the data is sorted
Data2 = randi(1e4, [10,1])/10;
% Display the starting data
[Data1, Data2]
% Set the mindist
mindist = 700;
% Loop through all the data, starting with the first number
i = 1;
% While we are not at the end of the data set ...
while i < numel(Data1)
% ...and while the distance to the next item is too small
while (i < numel(Data1)) && (Data1(i+1) - Data1(i) < mindist)
% Remove the next item from the data set
Data1(i+1) = [];
Data2(i+1) = [];
end
% Go to the next item in the data set
i = i + 1;
end
% Display the results
[Data1, Data2]
0 Kommentare
Siehe auch
Kategorien
Mehr zu Data Import from MATLAB finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!