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
 Origin Forum
 set values with Data(x1,x2,inc)

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
ubdli Posted - 11/18/2013 : 08:19:41 AM
Origin Ver. and Service Release (Select Help-->About Origin): 9.0.0 SR1
Operating System: Windows XP

Hi there,

I'm trying to fill up a column with values in a specific order, but I'm failing and i dont know why.

So this is what i typed into the dialog:


Please tell, what is the problem here?

The purpose is to fill up the X-column with values with a steady increment (e.g. up to row 100 000) and then to fill up the empty Y-column cells with zeros to get a higher resolution FFT-Analysis.

Looking forward to hearing from you,

Marius
11   L A T E S T    R E P L I E S    (Newest First)
ubdli Posted - 12/05/2013 : 09:38:23 AM
Hi Hideo Fujii, Hi Snow,

I could not make it work with Hideo Fujii's method but Snow's worked just fine.

Thank you very much!

That's what I was looking for :)

Thanks again

Marius
snowli Posted - 11/25/2013 : 4:58:23 PM
Hi Marius,

After importing your data,
choose Worksheet: Worksheet Script... menu.
In the dialog that opens,
Enter the script below in one line.
wks.nrows=100000;double inc=col(A)[2]-col(A)[1]; for( int ii = 20835 ; ii <= wks.nrows ; ii++ ) {col(A)[ii]=col(A)[ii-1]+inc; col(B)[ii]=0;}

Check After Import checkbox.
Click Do it to see if the script works.

Save the workbook as Test.otw. //the script will be saved in the template and will execute after import.

Try to import ascii and check Show Options. Choose Start New Workbook and choose Test.otw.


Thanks, Snow
OriginLab Corp.
Hideo Fujii Posted - 11/25/2013 : 11:21:57 AM
Hi Marius,

I think you can use a Conditional Operator in the Set Column Values tool:
<cond-1>?><VALUE_ON_TRUE>:<VALUE_ON_FALSE>
such as in the following screenshot:



where:
- Row[1] was set from the 1st row to the end of the row of your choice.
- xi1 is the row number where you wanted to start applying the formula.
- xx1 is the initial value at xi1.
- inc is the increment.
- the formula
i<xi1?col(B)[i]:xx1+(i-xi1)*inc
preserves the original values until xi1 then start computing with the initial and the increment.

Does it work in your case?

--Hideo Fujii
OriginLab
ubdli Posted - 11/20/2013 : 04:54:41 AM
Hello,
I'am sorry, I think I did not make myself clear.
My explanations probably were too short.

After what I learned in the last days, this is what I was trying to do right now (including the latest trouble :P)

First I imported a file with 20834 rows of measured data.

Then I wanted to add more rows to this table.
This additional rows should have the following attributes:
- ongoing X-axis (time) with a constant increment, linear from row 1 to 100000
- every Y-axis cell from row 20834+1 to row 100000 should get filled with the value zero
I want my table to be that way because like this a Fast Fourier Analysis is in higher resolution.

Filling the Y-axis was no problem, for the X-axis I started this topic. So after it didn't work at all, because I forgot the dot/comma problem, it turned out that the following command produced a step in the progression of X-axis values:

My increment is 4.99979E-4 - 4.99931E-4 = 4.8E-8,
for contionous progression i chose x1 = 4.99979E-4 + inc = 5.00027E-4
and to counter the mentioned amount of values problem [ (x2-x1)/inc ] I chose x2 = 1.

The result is also in the picture above.
(It always shows the rounded value 0.0015.)

So now I think I understand what Greg meant and what is shown in your last example Zheng. Please correct me if I'm wrong.

This algorithm always starts in row 1 and calculates the values for every cell. But it only fills in the values in the declared range. When the range is too big and there are no more values to calculate (final value x2), the remaining cells get filled with "--".

So when i tried to fill in my cells with
X1 = 5.00027E-4
X2 = 1E-3
INC = 4.7999999999997E-8
(X2 - X1)/INC = 10416.104 = 10417
,I only got "--" in my desired range, because the alg had already stop calculating in row 10417.
Nevertheless my screenshot displayed values up to row 20834. But these 20k rows were already filled, before I opened the "Set Values" dialog. Every existing value in X and Y up to row 20834 originate from my earlier import.

In order to get my desired linear slope, I created the values in another sheet and copy-pasted them into my table.
Now I had my desired table form.

To skip this process for the next imports, I then saved my table as a .ogw file. But it turns out I can't use it as a template for the next import.
I guess thats because there are no saved commands, since I didnt induce the additional data in this worksheet but copied it in.

To generate my additional data in the same workbook I want to save as .ogw file, I chose another start value x1 = X(Row 1) for my "Set Value" function to shift my funcion in the right place.
After running the algorithm I had the desired result.

Then: next try with saving it as a .ogw-file, starting a new project and importing measured data. Like Zheng said I chose "Import Mode" to be Start New Books and chose my saved .ogw file in "Template Name".

Unfortunately I did not succeed.
Hopefully this is enough information to understand my situation.


Kind regards,

Marius
lkb0221 Posted - 11/19/2013 : 11:54:40 AM
Hi, Marius

OK, I see where your problem is.

First, the parameter in Data(x1,x2,inc) means Start Value, End Value, Step Increment Value
In your script:
X1 = 5.00027E-4
X2 = 1E-3
INC = 4.7999999999997E-8
The maximum number of values you created by this command (X2 - X1)/INC = 10416.104 = 10417

Your Data(x1,x2,inc) created a loose dataset with the size of 10417. So when you set to fill column form row 20835, they are missing values because there is no value in those rows in this loose dataset.

For example, see this simple case:


So I think you need to set those value in a new column and then copy and paste to Col(A) then.

Is there any particular reason why you really need to set partial column value?

Thanks,
Zheng
OriginLab
ubdli Posted - 11/19/2013 : 11:28:31 AM
Thank you very much!
I will try this tomorrow :)

@Greg: I'm not sure if I got you right there.
By using this command i created ~80000 values up to row 100000.
I thought the variable x2 stands for any value the command counts to and then stops. Otherwise the algorithm stops when the specified row is reached.
So i just entered a x2 value that will never be reached within 80000 steps to fill up my 100k rows completely.

What exactly are you wondering about?
lkb0221 Posted - 11/19/2013 : 10:23:32 AM
Hi, Marius

You can save this workbook you are working on as an ogw file (Test.ogw for example).
Next time when you import another ASCII file with the same data(column) structure, in impASC dialog, set "Import Mode" be Start New Books and choose this ogw file in "Template Name".
Then all the set column settings will be applied to the new imported file.

Best,
Zheng
OriginLab
greg Posted - 11/19/2013 : 09:57:37 AM
By using the data function ( which returns a vector ) and using the form which specifies an increment, you have also defined the number of values: (x2 - x1) / inc.
Your range of row values is more than the data function returns.

Curiously, I get only 10416.104166667 (1047 rows) while you seem to be getting twice as many values.

P.S. The double type definitions are not needed since LabTalk treats all untyped numerics as double.
ubdli Posted - 11/19/2013 : 09:47:36 AM
After some testing I found out that the problem was the usage of a comma's in the "Before Formula Scripts" field...

Anyway I got another question:

How can I put this command into some lines of LabTalk to attach it to an ASCII import filter?
I dont want to do this step for several workbooks over and over again.
ubdli Posted - 11/19/2013 : 02:25:49 AM
Thanks for your reply Zheng, but it did not work out yet.

According to your advice I entered the following lines:


Unfortunately this command produced " -- ".

What is the problem now?

Greetings
lkb0221 Posted - 11/18/2013 : 10:51:00 AM
Hi, Marius

The problem is in your "Before Formula Scripts".
When you are giving "x1" value, the "inc" is not defined yet.
Please move the "inc=" to the first line and try again to see if it's what you want.

And, you need to define the type of all your parameters (in your case, can simply add "double" to each line of the script), like
Double x2 = 1E-3;


Thanks,
Zheng
OriginLab

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