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
 calculation across 2 worksheet s

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
fastelectron Posted - 07/26/2013 : 02:44:18 AM
Origin Ver. : 8.5
Service Release : SR1
Operating System: Windows 7

Hi ,

I am facing a tedious task in some calculation.

I have 2 worksheets, say A and B.

A has 2 cols and n rows.

B has n+1 cols and ~150 rows. (1st col X and the rest all Y)

Now I need to divide the first col and each subsequent col of B
with each row values of A.

ie,

xn = B(1st col) / A(n row,1 col)

and

yn = B(nth col) / A(n row,2 col)

for all values of n.

I am having 8 such (A,B) pairs of worksheets, and I am already
crossing all the limits of sanity.

somebody plz save me.

thanks alot

-S.

---
1   L A T E S T    R E P L I E S    (Newest First)
Penn Posted - 08/01/2013 : 11:12:42 PM
Hi,

If I have understood what you want, the following LabTalk script can be referred to. This script will create a new workbook for the output data. For each column in sheet B, it will be divided by each row value in column 1 or 2 in sheet A, that is to say, if there are n rows in sheet A, there will be n output columns for each column in sheet B. So the number of columns in the output sheet will be the number of columns in sheet B multiplied by n.

int n = 5;  // n rows in A, n+1 columns in B
range rAcol1 = [book1]A!col(1);  // assume sheet A's book is book1, range to column 1
range rAcol2 = [book1]A!col(2);  // assume sheet B's book is book1, range to column 2
range rB = [book1]B!;  // range to sheet B
newbook;  // create a new book for the output data
wks.nCols = rB.nCols*n;  // set the number of columns in the output sheet (active one)
for(int ii = 1; ii <= n; ii++)  // n rows
{
	for(int jj = 1; jj <= n+1; jj++)  // n+1 columns
	{
		range rBcoljj = [book1]B!wcol(jj);  // column jj in sheet B
		if(jj == 1)  // x column
		{
			wcol(jj+(ii-1)*(n+1)) = rBcoljj/rAcol1[ii];
			wks.col$(jj+(ii-1)*(n+1)).type = 4;  // set as x column
		}
		else  // y column
		{
			wcol(jj+(ii-1)*(n+1)) = rBcoljj/rAcol2[ii];
		}
	}
}


Penn

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