Only keep positve values from a matrix and plot the last of those values.

3 ビュー (過去 30 日間)
Mikkel Christensen
Mikkel Christensen 2020 年 5 月 1 日
コメント済み: Ameer Hamza 2020 年 5 月 1 日
Hello
I have a matrix (1001x50001) and I want to plot the last potive value of each column. The problem is that the last positve value changes position every now and then to the next row.
How do I plot a graph of these value?
I have tried to save all the positve elements from the matrix as a new variable, but I end up with a very long vector.
sPositive = s(s>0)

採用された回答

Ameer Hamza
Ameer Hamza 2020 年 5 月 1 日
編集済み: Ameer Hamza 2020 年 5 月 1 日
try this
s = randn(100, 200); % random vector
[~,r] = max(flipud(s)>0);
r = size(s,1)-r+1;
c = 1:size(s,2);
idx = sub2ind(size(s), r, c);
s_positive = s(idx);
s_positive is the first positive value in each column.
  8 件のコメント
Mikkel Christensen
Mikkel Christensen 2020 年 5 月 1 日
That's amazing, that did the trick.
Thank you very much!!!
Ameer Hamza
Ameer Hamza 2020 年 5 月 1 日
Great. I am glad to be of help.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDescriptive Statistics and Visualization についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by