Extracting and sorting data

3 ビュー (過去 30 日間)
Olu B
Olu B 2019 年 7 月 8 日
回答済み: Ruben Costa 2019 年 7 月 8 日
Hi I am trying to extract a large volume of data every 1 - 20 seconds time interval with a break of 5 seconds, also I want to specify a range for filtering the data before plotting e.g. temp range between 1.0 to 1.7 and I want the First column(time) to correspond to the selected data after filtering. For example I have two columns below:
Time temp
A = 1 1.3
2 1.7
3 0.3
4 0.8
Thanks
  1 件のコメント
Guillaume
Guillaume 2019 年 7 月 8 日
編集済み: Guillaume 2019 年 7 月 8 日
"I am trying to extract a large volume of data"
Extract from what? It appears you've given us the end result you want but not the starting point. An example of the starting data (in valid matlab syntax or as an attached mat file) would be useful.

サインインしてコメントする。

回答 (1 件)

Ruben Costa
Ruben Costa 2019 年 7 月 8 日
Hello, as Guillaume said it appears that you have given to us the matrix A in the form that you want.
For sorting a matrix that has different columns you can use the function sortrows! Below you can see a code that specifies what the function does!
A=[1 30 4 20; 0 0.3 0.5 0.7]' %Matrix with 2 columns
% A =
%
% 1.0000 0
% 30.0000 0.3000
% 4.0000 0.5000
% 20.0000 0.7000
B=sortrows(A,1) % 1 is the number of the column to sort by
% %Result
% B =
%
% 1.0000 0
% 4.0000 0.5000
% 20.0000 0.7000
% 30.0000 0.3000
C=sortrows(A,2) % This is the other option of sorting in this case
% C =
%
% 1.0000 0
% 30.0000 0.3000
% 4.0000 0.5000
% 20.0000 0.7000
You can see more about this function in https://www.mathworks.com/help/matlab/ref/sortrows.html
Hope i've helped you!

カテゴリ

Help Center および File ExchangeShifting and Sorting Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by