# Returning only positive values of a data set

6 ビュー (過去 30 日間)
jacob Mitch 2019 年 11 月 24 日
Answered: Star Strider 2019 年 11 月 24 日
If I a 3 row data set how would I return a new data set that only considers positive row 1 values for the first row
so If
Data=[1,-1,2,-1,3,4,5,-6;%x
1,2,3,4,-6,7,7,8;%y
6,2,3,4,5,6,7,8]%z
I want to get create a new data set with only x>0 values together with the corresponding y and z position values. So Im just getting rid of x<0 and corresponding y,z values So I would get
NewData=[1,2,3,4,5;%only positive x values
1,3,-6,7,7;6,3,5,6,7] %corresponding values in in that position%
%

#### 0 件のコメント

サインイン to comment.

### 件の回答 (1)

Star Strider 2019 年 11 月 24 日
You cannot do exactly as you want, because the resulting matrix dimensions would not be compatible.
Likely the best you can do is:
Data=[1,-1,2,-1,3,4,5,-6;%x
1,2,3,4,-6,7,7,8;%y
6,2,3,4,5,6,7,8]%z
Pos = NaN(size(Data));
Lm = Data > 0;
Pos(Lm) = Data(Lm)
producing:
Data =
1 -1 2 -1 3 4 5 -6
1 2 3 4 -6 7 7 8
6 2 3 4 5 6 7 8
Pos =
1 NaN 2 NaN 3 4 5 NaN
1 2 3 4 NaN 7 7 8
6 2 3 4 5 6 7 8

#### 0 件のコメント

サインイン to comment.

サインイン してこの質問に回答します。

Translated by