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
 Origin Forum
 sum of columns and rows
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

gelokkir2

Greece
5 Posts

Posted - 03/16/2003 :  1:54:50 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Hi,
I have a worksheet which is for example 2x2 (2 columns and 2 rows)
If I add a third column and row, how can I make origin to put the sums of the previous columns-rows in them? Please see below for an example of what I mean:

5 10 ..15
6 11 ..17
.. ..
11 21

Thank you for your help.

greg

USA
1378 Posts

Posted - 03/20/2003 :  2:42:32 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
I suspect you are thinking of an Origin worksheet as a spreadsheet, which is not a good idea. I think you will end up struggling with Origin rather than letting it work for you.

You can get the sum of a column range as follows:

begin = 1; // or whatever
end = 3; // or whatever
set col(1) -bs begin;set col(1) -es end;sum(col(1));
type Sum from $(begin) to $(end) is $(sum.total).;

and of a row range with:

startcolumn = 1; // or whatever
endcolumn = 2; // or whatever
row = 2; // or whatever
sum = 0;
loop(ii,startcolumn,endcolumn) {
sum += wcol(ii)[row];
};
type Sum from $(startcolumn) to $(endcolumn) is $(sum).;

For your simple example:

win -t data origin;
col(1)={5,6};
col(2)={10,11};
wo -a 1;
// Do the row sums
loop(ii,1,2) {
sum = 0;
loop(jj,1,2) {
sum += wcol(jj)[ii];
}
wcol(3)[ii] = sum;
}
// Do the column sums
set col(1) -bs begin;set col(1) -es end;sum(col(1));
set col(1) -e 3;
col(1)[3] = sum.total;
set col(2) -bs begin;set col(2) -es end;sum(col(2));
set col(2) -e 3;
col(2)[3] = sum.total;


Go to Top of Page

gelokkir2

Greece
5 Posts

Posted - 03/22/2003 :  4:00:41 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thank you very much!
I'll try it now.
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