フィルターのクリア

Finding the index of a particular point

6 ビュー (過去 30 日間)
SAZZAD HOSSAIN
SAZZAD HOSSAIN 2013 年 6 月 1 日
Hello all,
I am working with a curve having 1000 points along horizontal axis. Lets say that the value is zero along the curve up to 300th point and then it starts to increase smoothly and saturates to +1 at 700th point. Beyond that the curve remains unchanged at +1 till the end. The min and max value of the curve do not change, but the points from which they start to vary change when i run a loop;
start:
n(1:300) = 0; n(701:end) = 1;
first iteration:
n(1:255) = 0; n(706:end) = 1;
Second iteration:
n(1:250) = 0; n(711:end) = 1;
and so on;
I need to know the indices to these two points at which the changes start in each iteration. Can anyone please help me how i should write the codes to ge this?
Thanks Sazzad

採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2013 年 6 月 1 日
編集済み: Azzi Abdelmalek 2013 年 6 月 1 日
You can use
diff(n)
%Or
n=[0 0 0 0 0 0 0 0 0.5 0.6 .7 .8 .9 1 1 1 1 1 1 1 1]
idx1=find(n==0);
idx1=idx1(end) % first point
idx2=find(n==1,1)% second point

その他の回答 (1 件)

Andrei Bobrov
Andrei Bobrov 2013 年 6 月 1 日
s = n == 0 | n == 1;
s = s(:)';
out = [strfind(s,[1 0 ]), strfind(s,[0 1])+1];
  1 件のコメント
SAZZAD HOSSAIN
SAZZAD HOSSAIN 2013 年 6 月 1 日
Thanks Andrei. Works perfect

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

カテゴリ

Help Center および File ExchangeCharacters and Strings についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by