How to select a certain range in the middle of my data?

1 回表示 (過去 30 日間)
David
David 2022 年 7 月 5 日
回答済み: Star Strider 2022 年 7 月 5 日
I have a set of experimental data x,y. x goes between different values, and I want to remove a range of values inside (think x has values from 0 to 10 and I want to remove the range betweeen 5 and 6). How can I remove the values for both x and y data?
I am importing the data as follows:
RealData=Importdata('datafile.txt');
This gives me a matrix with x and y in two columns. The matrix will be different in different cases, so I want to be able to remove the data by giving the values of x between which I don't want the data, as the indexes will vary from case to case.
I have seen ways to remove data after a certain value, but not a range in the middle.

採用された回答

Star Strider
Star Strider 2022 年 7 月 5 日
There are different ways to do this.
One approach —
ReadDataX = 0:0.5:10
ReadDataX = 1×21
0 0.5000 1.0000 1.5000 2.0000 2.5000 3.0000 3.5000 4.0000 4.5000 5.0000 5.5000 6.0000 6.5000 7.0000 7.5000 8.0000 8.5000 9.0000 9.5000 10.0000
ReadDataY = randi(9,size(ReadDataX))
ReadDataY = 1×21
7 7 6 6 7 8 6 6 8 6 1 5 3 5 4 2 2 4 7 7 8
Lv = ReadDataX<5 | ReadDataX>6;
NewDataX = ReadDataX(Lv)
NewDataX = 1×18
0 0.5000 1.0000 1.5000 2.0000 2.5000 3.0000 3.5000 4.0000 4.5000 6.5000 7.0000 7.5000 8.0000 8.5000 9.0000 9.5000 10.0000
NewDataY = ReadDataY(Lv)
NewDataY = 1×18
7 7 6 6 7 8 6 6 8 6 5 4 2 2 4 7 7 8
.

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by