The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
 All Forums
 Origin Forum
 Origin Forum
 counting transition from +ve to -ve and vice verse

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
zango24 Posted - 02/24/2015 : 12:56:08 PM
Origin Ver. 8.6 and Service Release (Select Help-->About Origin):
Operating System:win 7

Dear all,
I am back with another query. I have a column with several numbers run from row 1 to row 800. Each row contain random numbers. Some with positive sign and some with negative sign. But these numbers and their sign occur randomly. I want to count how many times there is a transition between positive to negative and negative to positive.

Eg: column A contain these random numbers:
12
54
-76
32
56
1
-44
-3
-56
-12
41
44
84
-76
-12
-54
42
54
-76
46

So if I do it manually,it is simple. Like:
Positive to negative: 04 times.
Negative to positive: 04 times.

Any method to do it automatically?

Cheers,
Zen
3   L A T E S T    R E P L I E S    (Newest First)
Hideo Fujii Posted - 02/26/2015 : 2:12:48 PM
Hi Zen,

No need to say sorry as this is a very natural course that many people take to consider scripting.
The following script does such repetitive tasks for multiple columns in a worksheet using loops:
//////////////////////////////////
ncols=wks.ncols;
for(ii=1; ii<=ncols; ii++) {
  range rr=wcol(ii);
  nrows=rr.getsize();
  nneg=0;
  npos=0;
  for(jj=2; jj<=nrows; jj++) {
    if(wcol(ii)[jj-1]<0 && wcol(ii)[jj]>0) npos++; //count up positives
    else if(wcol(ii)[jj-1]>0 && wcol(ii)[jj]<0) nneg++; //count up negatives
  }
  type -a col:$(ii) colname:%(wks.col$(ii).name$) npos:$(npos)  nneg:$(nneg);
}
//////////////////////////////////

Maybe it's a time for you to challenge scripting so that you can freely create/modify it for your own needs?
8-)

--Hideo Fujii
zango24 Posted - 02/26/2015 : 1:18:23 PM
Hi Hideo,
Thanks for your quick response. Your suggestions are working wonderfully. So its somehow better than manual calculations and counting. But it involves treating each column as one at a time. I wonder if there is a way around to get the work done for multi columns of the same worksheet..... and if possible... multi columns in multi worksheets....

I know I am becoming bit greedy sorry about that....
Thanks for your support,
Cheers
Zen
Hideo Fujii Posted - 02/24/2015 : 2:58:23 PM
Hi Zen,

One way is to use Set Column Values tool as below:



Here, the columns F and G show the number of cases of Negative->Positive, and Positive->Negative, respectively.
Of course, you can consolidate formulae to fewer.

--Hideo Fujii
OriginLab

P.S. You can also run the Discrete Frequency on the column C.

P.P.S. The above method should work with 0's if it's okay not to count the transition to/from a zero. If you need to count the transitions like [+,0,...,0,-] , [-,0,...,0,+], [+,0,...,0,+], or [-,0,...,0,-], you need more sophisticated logic.

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000