07-05-2007 01:04 AM
I have two channels with values, one called moment and one called angle. Now I have to search in the moment channel the first value nearst 0.1Nm then I have to take one value before, the found value and one value after, make the arithmetic mean of this three and write it in a new channel called moment_short. I have also to take the arithmetic mean of the three angle values belonging to the moment values. This values I have to write in a channel called angle_short. This I have to do for moment values from 0Nm to 10Nm, down to -10Nm and back to 0Nm in 0.1Nm steps
The goal is, to have in the new channels always 401 values independent of the sample rate.
07-05-2007 02:05 AM
Option Explicit
dim x
dim rowLong : rowLong = 1
dim rowShort : rowShort = 1
dim cX : cX = 1
dim cY : cY = 2
dim cXs : cXs = cno(chnalloc(cn(cx)&"_short",401)(0))
dim cYs : cYs = cno(chnalloc(cn(cY)&"_short",401)(0))
for x = 0 to 10 Step 0.1
rowLong = chnfind("Ch("&cX&")>="&str(x),rowLong)
if rowLong > 1 then
chdx(rowShort,cXs) = (chdx(rowLong-1,cX)+chdx(rowLong,cX)+chdx(rowLong+1,cX))/3
chdx(rowShort,cYs) = (chdx(rowLong-1,cY)+chdx(rowLong,cY)+chdx(rowLong+1,cY))/3
rowShort = rowShort+1
end if
next
cl(cXs) = rowshort-1
cl(cYs) = rowshort-1
07-05-2007 04:21 AM
07-10-2007 01:30 AM
Hi
I tried on the base of your code some other mathematics. Now I have the problem, if I add the values together, then it works, if I subtract the values, it didn’t work. Why?
chdx(rowShort,cXs) = (chdx(rowLong,cY)+chdx(rowLong+1,cY))/(chdx(rowLong,cX)+ chdx(rowLong+1,cX)) -> works
chdx(rowShort,cXs) = (chdx(rowLong,cY)-chdx(rowLong+1,cY))/(chdx(rowLong,cX)- chdx(rowLong+1,cX)) -> didn’t work
07-10-2007 01:50 AM
07-11-2007 12:56 AM
Hi,
At the attached zip is the code and a dataset. When I start the script it works until the sub differenzieren2. Then there is an error message with the text “overflow” this message refers to the line in which I have the following code:
chdx(rowShort,cXs) = (chdx(rowLong,cY)-chdx(rowLong+1,cY))/(chdx(rowLong,cX)- chdx(rowLong+1,cX)) -> didn’t work
At the bottom, i have no additional infos.
If I change - to + it works.
07-11-2007 03:28 AM