How to trim a data to same dimension?

5 ビュー (過去 30 日間)
AbelM Kusemererwa
AbelM Kusemererwa 2015 年 7 月 15 日
コメント済み: Guillaume 2015 年 7 月 15 日
Data contains 2 columns (plan and T). However, plan contains some NaN. I would like to delete the NaN from plan and also its corresponding values in T so that the good data from columns plan and T will be of the same dimension

採用された回答

Guillaume
Guillaume 2015 年 7 月 15 日
Assuming data is an m x 2 matrix, it's simply:
Data(isnan(Data(:, 1)), :) = []
That is, find the nan in the first column of Data ( isnan(Data(:, 1))), and removes all the rows for which isnan is true ( Data(trueorfalse, :) = [])
  4 件のコメント
AbelM Kusemererwa
AbelM Kusemererwa 2015 年 7 月 15 日
編集済み: AbelM Kusemererwa 2015 年 7 月 15 日
Please, after deleting I would want to give them different names. How do I store them separately after deleting?
Guillaume
Guillaume 2015 年 7 月 15 日
Then you don't delete, you only copy the data you want to keep (everything that is not nan)
tokeep = ~isnan(plan); %use ~ for logical not
newplan = plan(tokeep);
newT = T(tokeep);

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

その他の回答 (0 件)

カテゴリ

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

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by