Extract data with specific range
154 ビュー (過去 30 日間)
古いコメントを表示
Nyam Jargalsaikhan
2023 年 6 月 29 日
コメント済み: Nyam Jargalsaikhan
2023 年 7 月 2 日
Hi all, I have this data with 3 columns and 96824 rows.
So, what i want is that only data between 12 to 15 value that represented in first line and correspoding the columns data.
for example: first rows can included data I want something like: 9.7; 1.2393; 59.7758.
Thank you so much
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1422143/image.jpeg)
0 件のコメント
採用された回答
Sushma Swaraj
2023 年 6 月 29 日
Hi, I got to understand that you are trying to get the subset of data where you would like to extract all the rows that contain value between 12 to 15 in the first COLUMN.
% Assuming your data is stored in a varibale named 'data':
% Extract the rows where the first column value is between 12 and 15
rowsNeeded = data(:,1) > 12 & data(:,1) < 15;
subsetData = data(rowsNeeded, :);
In the above code, data(:,1) represents the values in the first column of your data. The logical expression data(:, 1) > 12 & data(:,1) < 15 creates a logical index of rows where the first column values satisfy the condition between 12 to 15. Then, 'subsetData' stores the subset of data that meets this criterion, including all columns.
Hope it works!
その他の回答 (1 件)
Arya Chandan Reddy
2023 年 6 月 29 日
編集済み: Arya Chandan Reddy
2023 年 6 月 29 日
Hi, as I can see you are trying to select rows with data within the specified range. Assuming that "first line" in the second sentence of your query means "first column" (i.e : select those rows whose first column lies between 12 and 15) you can try something like:
idx = A(:,1) > 12 & A(:,1) < 15; %corresponding indices are set to 1
extractedData = A(idx, :);
Hope it helps.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Time Series Events についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!