DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

How to multiply channel by variable

Solved!
Go to solution

Hi,

I have a time stamp which is not real time, but next number. I know the interval (like 1 or 10 seconds) of measurements. So, I'm converting this to normal time. In this case I need to multiply this channel by specific interval. This is easy, because you can multiply channel by a constant like below:

  Call ChnCalculate("Ch(""[2]/Seconds1"")= Ch(""[1]/#"") * 1")
  Call ChnCalculate("Ch(""[2]/Minutes1"")= Ch(""[2]/Seconds1"") / 60")
  Call ChnCalculate("Ch(""[2]/Hours1"")= Ch(""[2]/Minutes1"") / 60")

But how to do this using variable? Let's say we have variable s_interval and we want to put this variable instead of multiply it by constant .

Ch(""[1]/#"") * 1")

Do you know how to do this?

 

Best regards,

Piotr

0 Kudos
Message 1 of 3
(3,947 Views)
Solution
Accepted by topic author Piotr_Samek

Hi Piotr,

 

You can define it like this:

dim dFactor
Call ChnCalculate("Ch(""[2]/Noise_1"")= Ch(""[2]/Noise_1"") / " & dFactor)

But I would prefer a DIAdem function for this calculation because it is faster using a well defined function than the calculator.

dim dFactor, dOffset
dFactor = 10
dOffset = 0
Call ChnLinScale("[1]/Time", "[1]/Time", dFactor, dOffset)

or if you use the channel object:

dim oChn, dFactor, dOffset
set oChn = Data.GetChannel("[1]/Time")
dFactor = 10
dOffset = 0
Call ChnLinScale(oChn, , oChn, dFactor, dOffset)

Greetings

Walter

Message 2 of 3
(3,926 Views)

Thank you Walter! It works perfectly 😉

 

Best regards,

Piotr

0 Kudos
Message 3 of 3
(3,922 Views)