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 add for loop to csetvalue formula
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

Skaytex

Lithuania
7 Posts

Posted - 02/12/2014 :  12:24:45 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver 8,6

Hello anyone knows how to add for loop to this csetvalue formula:

range r1=[r1]r1!2;
range r2=[r2]r2!2;
range r3=[r3]r3!2;

range st=[a]Sheet1!14;
range rd=[a]Sheet1!13;

range r11=[r11]r11!2;
range r12=[r12]r12!2;

csetvalue formula:="((r1*st[1]-r11*st[11])*4*1,38E-23*295*8191)/((r12*st[12]-r11*st[11])*rd[1]^2)" col:=2;
csetvalue formula:="((r2*st[2]-r11*st[11])*4*1,38E-23*295*8191)/((r12*st[12]-r11*st[11])*rd[2]^2)" col:=3;
csetvalue formula:="((r3*st[3]-r11*st[11])*4*1,38E-23*295*8191)/((r12*st[12]-r11*st[11])*rd[3]^2)" col:=4;

i want 3 or more times rewind this formula...

and is it possible to add for loop for this:

range r1=[r1]r1!2;
range r2=[r2]r2!2;
range r3=[r3]r3!2;
range r4=[r4]r4!2;
range r5=[r5]r5!2;
range r6=[r6]r6!2;
range r7=[r7]r7!2;
range r8=[r8]r8!2;
range r9=[r9]r9!2;
range r10=[r10]r10!2;
range r11=[r11]r11!2;
range r12=[r12]r12!2;

KF

Edited by - Skaytex on 02/12/2014 12:31:03 PM

lkb0221

China
497 Posts

Posted - 02/12/2014 :  1:23:20 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,
please try the following strcture

//
range st=[a]Sheet1!14;
range rd=[a]Sheet1!13;
range r11=[r11]r11!2;
range r12=[r12]r12!2; // Declare the variables that will not change in the loop
loop(ii,1,10) // loop from 1 to 10
{
range rr = [r$(ii)]r$(ii)!2;
csetvalue formula:="((rr*st[$(ii)]-r11*st[11])*4*1.38E-23*295*8191)/((r12*st[12]-r11*st[11])*rd[3]^2)" col:=$(ii+1);
}
//

Notice that I changed the decimal separator from comma to dot in "...st[11])*4*1.38E-23*295..." because of my settings.

Zheng
OriginLab

Edited by - lkb0221 on 02/12/2014 1:33:03 PM
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