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
 select specific rows for calculation
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

EmiliaSeltsam

Germany
3 Posts

Posted - 04/29/2020 :  5:58:52 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. 2016G
Operating System: Windows 10

I like to perform simple calculation on data in a column, but use only selected rows.
If I use the Command Window I can do:
col(C)=90-col(B)
which will perform the calculation on all rows.
I want the calculation on every 3rd row, i.e. 1st, 4th, 7th ... and the other data should be just copied as they are.
I tried:
for (ii =1; ii <=wks.maxrows; ii +=3)
{col(3)=90-col(2)[ii]}
but this gives a constant value in the 3rd column.
Can anyone help? Thanks.

Edited by - EmiliaSeltsam on 04/29/2020 6:01:14 PM

aplotnikov

Germany
170 Posts

Posted - 04/29/2020 :  6:33:26 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
col(3)[ii]=90-col(2)[ii]
Go to Top of Page

EmiliaSeltsam

Germany
3 Posts

Posted - 04/29/2020 :  6:39:11 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks for the fast reply :-)
But problem remains the same: col(3) is filled with the same value on all rows ...
Go to Top of Page

aplotnikov

Germany
170 Posts

Posted - 04/29/2020 :  6:49:52 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
I have checked - everything works fine. You may need to initialize the third column before calculations.


Edited by - aplotnikov on 04/29/2020 6:50:51 PM
Go to Top of Page

EmiliaSeltsam

Germany
3 Posts

Posted - 04/30/2020 :  01:28:35 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
yes, it basically works.
I cleared col(3) and then performed the script, and it does the calculation on every 3rd row.
But it does not copy the other data from col(2).
My workaround is to copy col(2) to col(3) and then run the script, which gives me what I want.
THANKS A LOT.
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