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 for Programming
 LabTalk Forum
 how to set column value for a set length

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
ywh Posted - 11/12/2014 : 2:42:55 PM
Origin Ver. and Service Release (Select Help-->About Origin):
Operating System:

Hi there. I'm new to Origin and would like some help/guidance on how to do the following:

I have a column of numbers that serve as an indicator. Most of the numbers are 1s, with occasional 10s. I want to make a new column that has mostly 1s, but when it sees a 10 in the indicator column, I want the next 2500 numbers to be 2.
Say the column of indicator is col(K), and the new column I will make is col(F).
I have written the following script, but it didn't work. Any help will be appreciated. Thanks a lot!
---------------------------------------------------------
int flag= 0;
int counter = 0;

for (ii=0; ii< 20000; ii++)
{
if ( col(K)[ii] == 10 )
{
flag = 1;
counter = 0;
}
if (flag == 1)
{
if (counter < 2500) {
col(L)[ii] = 2;
}
else
{
flag = 0;
}
}
counter++;
}
2   L A T E S T    R E P L I E S    (Newest First)
ywh Posted - 11/13/2014 : 1:38:53 PM
Thanks a lot!
lkb0221 Posted - 11/12/2014 : 3:56:44 PM

int ReplaceWin = 2500;
range rIndicator = col(K);
range rTarget = col(L);

int Value = 1;
int counter = 0;
for (int ii = 1; ii <= 20000; ii++)
{
rTarget[ii] = Value;

if (counter > 0) {
counter = counter - 1;
}
else {
Value = 1;
}

if (rIndicator[ii] == 10) {
Value = 2;
counter = ReplaceWin - 1;
}
}

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