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
 pass variables to col(n)[jj] notation
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

coll@inia.

Spain
125 Posts

Posted - 05/10/2012 :  2:05:04 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
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

coll@inia.

Spain
125 Posts

Posted - 05/10/2012 :  2:06:51 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
sorry I forgot!

can anybody help me?
thanks a lot!, julio
Go to Top of Page

Hideo Fujii

USA
1582 Posts

Posted - 05/10/2012 :  4:50:22 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
Go to Top of Page

coll@inia.

Spain
125 Posts

Posted - 05/11/2012 :  03:55:01 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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!
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