フィルターのクリア

Splitting a database up

1 回表示 (過去 30 日間)
Anna Mielcarek
Anna Mielcarek 2023 年 3 月 23 日
回答済み: Antoni Garcia-Herreros 2023 年 3 月 23 日
Hi,
I have a massive dataset of around 72,000 lines, and 30 rows.
In row 1 I have the date (in a DDMM format).
For each date I have a series of rows with data in, so the date repeats itself a fair amount.
I only want one row per date.
Currently, I have used:
[~,udix}= unique(data(:,1),'stable');
to read the first of the date lines, however is there a way to randomly select one of the repeating dates?

回答 (1 件)

Antoni Garcia-Herreros
Antoni Garcia-Herreros 2023 年 3 月 23 日
Hello Anna,
You can generate a random number using the rand function
n = floor(udix(1) + (udix(2)-1-udix(1)) .* rand(1,1));
% This generates a random number between the index of the first date and the index of the secon date
Hope this helps

カテゴリ

Help Center および File ExchangeDatabase Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by