HOW TO FIND THE LOCAL MAXIMA FOR EVERY ROW IN A MATRIX

Hii,
Hallo suppose if i have a 3x3 matrix like [0 -1.2 -0.6; -0.9 -5 -6; 0 -1.8 -2.5] and also I have a threshold value mentioned suppose let it be threshold > -1 I obtain results as [1 0 1; 1 0 0; 1 0 0] but what i need is a matrix which distinguishes the different intensities of results obtained above the threshold for ex: my results should look like [1 0 0.5; 1 0 0; 1 0 0]

回答 (1 件)

Geoff
Geoff 2012 年 3 月 19 日

0 投票

A = [0 -1.2 -0.6; -0.9 -5 -6; 0 -1.8 -2.5];
threshold = -1;
result = max( A - threshold, 0 );
Now, you seem to be only interested in 'intensities' that are multiples of 0.5. To get that, do this:
result = round(result * 2) / 2;

3 件のコメント

raj
raj 2012 年 3 月 19 日
Hii,
No, its not the case but I just gave it as an example that there must be difference between the values even though both the values are above threshold.
Geoff
Geoff 2012 年 3 月 19 日
So what if you divided each row of my result by its maximum value?
result = result ./ repmat( max(result,[],2), 1, size(result,2) );
Any row that is all zeros will become NaN, so:
result(isnan(result)) = 0;
Image Analyst
Image Analyst 2012 年 3 月 19 日
raj, you're clear as mud. No one knows why only the -0.6 should give a 0.5, while all the others should give a 1. Explain it better if you can't solve it yourself and want us to solve it for you.

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

カテゴリ

ヘルプ センター および File ExchangeCreating and Concatenating Matrices についてさらに検索

タグ

質問済み:

raj
2012 年 3 月 19 日

Community Treasure Hunt

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

Start Hunting!

Translated by