How can I remove some specific rows in which zero an nan values exist?

1 回表示 (過去 30 日間)
Behrooz Daneshian
Behrooz Daneshian 2023 年 1 月 20 日
編集済み: Matt J 2023 年 1 月 20 日
Hi all
I have a cell array called "stations2". I intend to remove simultanesly all rows for which the second column is zero or nan. How can I do that?
  3 件のコメント
Matt J
Matt J 2023 年 1 月 20 日
編集済み: Matt J 2023 年 1 月 20 日
No, your attached stations2.mat contains no cell arrays (which wouldn't be appropriate anyway).
Behrooz Daneshian
Behrooz Daneshian 2023 年 1 月 20 日
編集済み: Behrooz Daneshian 2023 年 1 月 20 日
oh my bad. It is a double

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

採用された回答

Matt J
Matt J 2023 年 1 月 20 日
編集済み: Matt J 2023 年 1 月 20 日
load stations2
cutrows=stations2(:,2)==0|isnan(stations2(:,2));
stations2
stations2 = 10×4
1.0e+03 * 2.0120 0.3690 0.0347 0.1830 2.0130 0.2155 0.0383 0.1360 2.0140 0 0.0478 NaN 2.0150 NaN NaN NaN 2.0160 0.1570 0.0431 0.0990 2.0170 0.0315 0.0420 0.1050 2.0180 0.0035 0.0437 0.0950 2.0190 0.0755 0.0417 0.1270 2.0200 0.2165 0.0385 0.1610 2.0210 0.3970 0.0353 0.1560
stations2(cutrows,:)=[]
stations2 = 8×4
1.0e+03 * 2.0120 0.3690 0.0347 0.1830 2.0130 0.2155 0.0383 0.1360 2.0160 0.1570 0.0431 0.0990 2.0170 0.0315 0.0420 0.1050 2.0180 0.0035 0.0437 0.0950 2.0190 0.0755 0.0417 0.1270 2.0200 0.2165 0.0385 0.1610 2.0210 0.3970 0.0353 0.1560
  2 件のコメント
Behrooz Daneshian
Behrooz Daneshian 2023 年 1 月 20 日
編集済み: Behrooz Daneshian 2023 年 1 月 20 日
It did not work
Matt J
Matt J 2023 年 1 月 20 日
I've edited the answer. Make sure you're running my latest version.

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

その他の回答 (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