How do i remove rows from a column based on the value of a corresponding column?
11 ビュー (過去 30 日間)
古いコメントを表示
I have a large amount of data that i need to process with Matlab but am quite a novice so unfamiliar with all but the basics. I effectively have a large data file containing thousands of entries and i need to know how i can remove a number of specific rows depending on the corresponding value if that makes any sense at all.
Column A is made up of depth values that range from .0000 to 2000.0000m and column B contains salinity values corresponding with each of these depths for a number of stations over a number of years. I want to find if i can remove all values from column B that correspond with values in column A that are less then or equal to 120.0000m.
If(A<=120.0000 then delete B)
I tried to convey this as best as i could in the expression above but don't know where to start with actual equations so any help would be much appreciated.
1 件のコメント
採用された回答
Wayne King
2013 年 3 月 28 日
編集済み: Wayne King
2013 年 3 月 28 日
Assume X is your data matrix,
Xnew = X(X(:,1)>120,:);
So for example:
X = randi(10,10,2);
Xnew = X(X(:,1)>6,:);
I'm assuming that by column A you mean the 1st column of the matrix.
0 件のコメント
その他の回答 (1 件)
Mahdi
2013 年 3 月 28 日
編集済み: Mahdi
2013 年 3 月 28 日
Remove=find(A<=120.0000);
B(Remove)=[];
If you also want to remove these values from matrix A, then
A(Remove)=[];
1 件のコメント
Mahdi
2013 年 3 月 28 日
The above assumes that you only have one column. If it's in the first column, use A(:,1) and B(Remove,1) and so on.
参考
カテゴリ
Help Center および File Exchange で Oceanography and Hydrology についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!