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
 pass variables to col(n)[jj] notation

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
coll@inia. Posted - 05/10/2012 : 2:05:04 PM
Origin Ver8.5. and Service Release (Select Help-->About Origin):
Operating System:win7

I am trying to make means and sd from several rows (data in col11) in a column according to a common name in another column (col7) by using the following script:
for(jj=2; jj<=10; jj++)
{
if(col(7)[jj]$==col(7)[jj+1]$)
{kk = kk + 1;}
else
{repes = kk;
ini = jj - repes + 1;
fin = jj;
//mean-sd calculation
range gen = [Data1]Sheet1!col(11)[$(ini):$(fin)];
sum(gen);
col(12)[$(ini):$(fin)]=sum.mean;
col(13)[$(ini):$(fin)]=sum.sd;
kk = 1;
} // end if
} //end for

However, I keep getting the following answer (see it down) for the mean-sd calculation, no matter what I do. I guess has something to do with string to numeric value conversion, however it does not take the ini/fin variables without any $().
Invalid dataset index: 2:3
Invalid dataset index: 2:3
Invalid dataset index: 4:6
Invalid dataset index: 4:6
Invalid dataset index: 7:10
Invalid dataset index: 7:10
3   L A T E S T    R E P L I E S    (Newest First)
coll@inia. Posted - 05/11/2012 : 03:55:01 AM
YES!!!
It really made the difference: THAN YOU SO MUCH!
I spent hours trying to find out a correct script.....
Thank you again Hideo.
Here is the final version of the script:


//Initiation
range via = [Data1]Sheet1!Col(7);
nRows=via.nRows-1;
kk = 1;

//from row by row
for(jj=2; jj<=nRows; jj++)
{
if(col(7)[jj]$==col(7)[jj+1]$)
{kk = kk + 1;}
else
{repes = kk;
ini = jj - repes + 1;
fin = jj;

//mean calculation mean
range gen = col(11)[ini:fin];
sum(gen);

range rr1 = col(12)[ini:fin];
rr1 = sum.mean;

range rr2 = col(13)[ini:fin];
rr2 = sum.sd;

kk = 1;
} // end else if

} //end for

type -c GREAT HIDEO!
Hideo Fujii Posted - 05/10/2012 : 4:50:22 PM
Hi julio,

At least the following expression without range notation won't work:

col(12)[$(ini):$(fin)]=sum.mean;

It should be like:

range rr=col(12)[ini:fin];
rr=sum.mean;

It helps?

--Hideo Fujii
OriginLab
coll@inia. Posted - 05/10/2012 : 2:06:51 PM
sorry I forgot!

can anybody help me?
thanks a lot!, julio

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