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
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 LabTalk Forum
 how to set column value for a set length
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

ywh

USA
4 Posts

Posted - 11/12/2014 :  2:42:55 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
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++;
}

lkb0221

China
497 Posts

Posted - 11/12/2014 :  3:56:44 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply

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;
}
}
Go to Top of Page

ywh

USA
4 Posts

Posted - 11/13/2014 :  1:38:53 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks a lot!
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000