フィルターのクリア

How to select columns in a matrix whose first row data is positive?

1 回表示 (過去 30 日間)
Misi
Misi 2022 年 7 月 21 日
コメント済み: Misi 2022 年 7 月 21 日
Greetings
I have this matrix:
A=[-1 2 5 4 -4;1 2 3 4 6]
I want to extract the data according to first row. Indeed, I want to extract the columns with positive data in the first row, for example for the above matrix I am searching for a code to give me the below matrix
ans=[2 5 4;2 3 4]

採用された回答

John D'Errico
John D'Errico 2022 年 7 月 21 日
Easy peasy.
A=[-1 2 5 4 -4;1 2 3 4 6]
A = 2×5
-1 2 5 4 -4 1 2 3 4 6
B = A(:,A(1,:) > 0)
B = 2×3
2 5 4 2 3 4

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by