03-17-2011 02:32 AM
Hi
I want to multiply all my channles with a constant value say 4.3
So I thought of generating a new channel with all its value as 4.3 and multiplying this channel with my current channel . I used
Dim MyChnName, i
MyChnName = ChnAlloc("Mass", 2400, 1,DataTypeFloat64,"Numeric") 'Allocate text channel
For i = 1 to 200
CHT(i,MyChnName(0)) = "4.3" & i 'Create text value
Next
But it generates values as 4.31, 4.32, .....4.3xxx
I want all values to be constant. How can i modify my code to do this??
Or to multiply all my channle values with 4.3 directly(without creatin a channel) How to go ahead with this??
Solved! Go to Solution.
03-17-2011 02:53 AM
Hi Rash.patel,
Are you really talking about a text - which means "abc123...."? I think not because you define a numeric channel with chnalloc.And in the next line you connect tow strings: ...= "4.3" & i. In VBS a string connection just puts the strings together like "abc" & "123" -> "abc123". I think this is not what you would like to do. If you use a loo you must define: ... = 4.3 + i
But in general you should use the standard mathematical functions of DIAdem because they are much faster than a loop over the single channel values.
In the DIAdem Base Mathematic you find the functions you need, like Scaling, Offset correction ....
Greetings
Walter
03-18-2011 12:20 AM
Hey Walter,
Thanks for your idea. I modified my script like this and now I can generate a channel with all its value as 4.3.
MyChnName = ChnAlloc("Mass", 2400, 1,DataTypeFloat64,"Numeric") 'Allocate text channel
For i = 1 to 2400
CHT(i,MyChnName(0)) = 4.3 + 0 'Create text value
Next
03-18-2011 09:24 AM
Hi Patel,
This was not what Walter said at all-- he said to use the standard ANALYSIS functions for this sort of thing. The standard ANALYSIS functions are much faster and easier than a VBScript loop. Here's what you should use to create a channel like that instead:
Call ChnLinGen("Mass", 4.3, 4.3, 2400, "kg")
Brad Turpin
DIAdem Product Support Engineer
National Instruments