extracting x,y data from certain time points in matrix?
11 ビュー (過去 30 日間)
古いコメントを表示
Hello!
I have the txt file that looks as follows:
x y
.001 1
.002 3
.5 5
5 10
6 11
7 12
8 13
9 15
10 17
11 20
Where the first column is time and the second column is a changing value y.
I want to extract all the x,y values where x<=10 and x>= 5, e.g.
5 10
6 11
7 12
8 13
9 15
10 17
As of now the code I am using is (where srtm is the first code box above):
x = find(srtm(:, 1)> 5 & srtm(:,1) < 20)
and that just gives me the corresponding column numbers (4, 5, 6, 7, 8, 9), but not at x values.
My question is:
1) how to I extract the x, y coordinates from a matrix where x=> number1, x=<number2?
Thanks so much for all of your help!
0 件のコメント
採用された回答
Image Analyst
2021 年 7 月 25 日
Instead of
x = find(srtm(:, 1)> 5 & srtm(:,1) < 20)
to do masking from 5 to 10 inclusive, you need to change x to indexes, 20 to 10, and use <= and <=
x = srtm(:, 1);
y = srtm(:, 2);
% Find linear indexes in the range [5, 10].
indexes = find(x >= 5 & x <= 10) % Or could use logical indexes, like: indexes = x >= 5 & x <= 10
% Extract values in that range ONLY.
xm = x(indexes);
ym = y(indexes);
plot(xm, yb, 'b.-', 'LineWidth', 2, 'MarkerSize', 20);
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Behavior and Psychophysics についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!