フィルターのクリア

Extract the column/ row numbers or adress

3 ビュー (過去 30 日間)
Turbulence Analysis
Turbulence Analysis 2021 年 1 月 20 日
Hi,
I have 1 x 10000 matrix which got values of 0, 1 in it. Here, I would like to get the information on column numbers which got the value 1. Attached, here is th matrix. Please help me with this...
  3 件のコメント
Turbulence Analysis
Turbulence Analysis 2021 年 1 月 20 日
Thanks, I works perfectly..
dpb
dpb 2021 年 1 月 20 日
NB: Depending upon the next step(s), often one doesn't need to actually return the indices themselves but can simply use the logical addressing vector.
If so, may save a temporary variable plus the overhead of the find() operation itself.

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

採用された回答

Adam Danz
Adam Danz 2021 年 1 月 20 日
> I would like to get the information on column numbers which got the value 1
For logical row vectors or numeric row vectors containing 1|0,
colNum = find(c);
If the row vector contains values other than 0|1 and you want to find the 1s, follow Omid Saeidi's advice,
colNum = find(c==1);
If you're planning on indexing, follow dpb's advice and use logical indexing
logidx = logical(c); % if c is numeric
% or
logidx = c==1; % if c contains values outside of 0|1
  3 件のコメント
Adam Danz
Adam Danz 2021 年 1 月 20 日
I would define the sequences within a variable and loop through each sequence.
seq = {55:65; 125:145; 201:225};
for j = 1:numel(seq)
for kk = seq{j}
% your code
end
end
Turbulence Analysis
Turbulence Analysis 2021 年 1 月 20 日
Thanks.. It's perfect..

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by