フィルターのクリア

Help with Matalab code in detecting sign change in a Vector

4 ビュー (過去 30 日間)
Lanz500
Lanz500 2014 年 2 月 24 日
回答済み: Lanz500 2014 年 3 月 6 日
If i have a vector for example X[M,N] and I want to get a new vector with values of 1 if there is a sign change across the values of N for every M row and a 0 if not then how do I write this code conditional to the N1*N2 ... Nn*Nn+1<0 So what I am after is a new vector with only M columns of 1 and 0 1 if there is a sign change across my Ns (conditional to Nn*Nn+1<0) 0 if there is no sign change across my Ns using function any thanks

回答 (3 件)

Giorgos Papakonstantinou
Giorgos Papakonstantinou 2014 年 3 月 3 日
First part:
C = sign(diff(A, [],2))% size(M, N-1); %1 for positive, 0 for no change, -1, for negative
Second part
D =any(C==-1, 2);

Iain
Iain 2014 年 3 月 3 日
minsign = sign(min(A));
maxsign = sign(max(A));
answer_vector(numel(minsign)) = false;
answer_vector(minsign==-1 & maxsign==1) = true;
answer_vector(minsign==1 & maxsign==-1) = true;
That works for columns. Transpose A, or use the additional arguments available to min & max to do it for rows.

Lanz500
Lanz500 2014 年 3 月 6 日
Hello guys and thanks so much for your help really appreciated

カテゴリ

Help Center および File ExchangeMatched Filter and Ambiguity Function についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by