-
FlexPro
- At a Glance
- Features & Options
- Applications
- All Advantages
- What’s New in FlexPro 2021
- Try FlexPro For Free
- FlexPro View OEM Freeware
- Buying Guide
- Login
- Language
- +49 6894 929600
- infoweisang.com
- Google Maps
- Products
- News
- Support
- Company
- Contact
- Login
- Language
- +49 6894 929600
- infoweisang.com
- Google Maps
if condition
- This topic has 8 replies, 2 voices, and was last updated 17 years, 11 months ago by Dirk Kampffmeyer.
-
AuthorPosts
-
November 30, 2006 at 2:42 am #12506Dirk KampffmeyerParticipant
I have serious problems to implement `if` conditions. For instance I have to calculate dewpoints which is not any obstacle, but afterwards I attempt to sum these dewpoints up to partial pressures and it doesn`t work. To illustrate my problem I give the program code:
dim tau,pv,i,s,ppm
For Each Row i In CH1 Do
tau=ch1.Y/2*130-110 // dewpoint
if tau<0 then
pv=611.15*exp(22.542*tau/(tau+273.48)); // partial pressure
else
pv=611.21*exp(17.502*tau/(240.97+(tau*65-110)));
end
ppm=pv/101325*10^6end
November 30, 2006 at 2:42 am #8169Dirk KampffmeyerParticipantI have serious problems to implement `if` conditions. For instance I have to calculate dewpoints which is not any obstacle, but afterwards I attempt to sum these dewpoints up to partial pressures and it doesn`t work. To illustrate my problem I give the program code:
dim tau,pv,i,s,ppm
For Each Row i In CH1 Do
tau=ch1.Y/2*130-110 // dewpoint
if tau<0 then
pv=611.15*exp(22.542*tau/(tau+273.48)); // partial pressure
else
pv=611.21*exp(17.502*tau/(240.97+(tau*65-110)));
end
ppm=pv/101325*10^6end
November 30, 2006 at 3:55 am #8806Bernhard KantzParticipantYou have forgotten to return the result:
For ... End ppm //or return ppm
But in this case the result is only the ppm of the last value. If you want to calculate the ppm of each value try this
Dim tau = ch1.Y/2*130-110 // dewpoint Dim idxAbove = ValuesAboveLevel(tau, 0, EVENT_INDEX) tau = 611.15*exp(22.542*tau/(tau+273.48)) // partial pressure tau[idxAbove] = 611.21*exp(17.502*tau[idxAbove]/(240.97+(tau[idxAbove]*65-110))) tau/101325*10^6
FPScript is a vectorial script language. Therefore you need no loop to manipulate the whole signal.
December 2, 2006 at 1:30 am #8807Dirk KampffmeyerParticipantThank you for your support. The formula is working rather well, but if the signal is rising up to 1.7 the results become too high.
Signal:
21 1,68925
22 1,71725
23 1,7133125
24 1,735625
25 1,732875
26 1,736
27 1,7446875
28 1,7549375
29 1,758875
30 1,7646875
31 1,7715625
32 1,7709375
33 1,769125
34 1,77425
35 1,770125
36 1,76425
37 1,7693125
38 1,77175
39 1,7569375
40 1,762
41 1,7371875
42 1,7355
43 1,7155625
44 1,692125
Results:
21 5933,50484
22 2696401011
23 2514035768
24 3697558728
25 3530971112
26 3720759050
27 4291879038
28 5053249400
29 5372463216
30 5872151797
31 6508674208
32 6448717840
33 6277230852
34 6771345639
35 6371406764
36 5833334034
37 6294807061
38 6526743852
39 5213478477
40 5636824868
41 3795002615
42 3689851293
43 2616946068
44 6025,680376I really do not know what the formula sums up.
Code:
Dim tau = ch1.Y/2*130-110 // dewpoint
Dim idxAbove = ValuesAboveLevel(tau, 0, EVENT_INDEX)
tau = 611.15*exp(22.542*tau/(tau+273.48)) // partial pressure
tau[idxAbove] = 611.21*exp(17.502*tau[idxAbove]/(240.97+(tau[idxAbove])))
tau/101325*10^6December 2, 2006 at 1:48 am #8808Bernhard KantzParticipantUse
tau[idxAbove] = 611.21*exp(17.502*tau[idxAbove]/(240.97+(tau[idxAbove]*65-110)))
instead of
tau[idxAbove] = 611.21*exp(17.502*tau[idxAbove]/(240.97+(tau[idxAbove])))
December 4, 2006 at 8:35 pm #8809Dirk KampffmeyerParticipantThe problem, however, is that I modified my formula. That is why I need the new one:
tau[idxAbove] = 611.21*exp(17.502*tau[idxAbove]/(240.97+(tau[idxAbove])))
I sumed it up by my calculator and there was not such high figure as result.December 4, 2006 at 10:54 pm #8810Bernhard KantzParticipantThe code “tau = …” changes all tau values. Therefore the next line uses the wrong values to calculate the values above 0.
Use the IndexNot function to calculate the indices of tau values below 0.
Dim tau = ch1.Y/2*130-110 Dim idxAbove = ValuesAboveLevel(tau, 0, EVENT_INDEX) Dim idxBelow = IndexNot(idxAbove, NumberOfRows(ch1)) tau[idxBelow] = 611.15*exp(22.542*tau[idxBelow]/(tau+273.48)) tau[idxAbove] = 611.21*exp(17.502*tau[idxAbove]/(240.97+(tau[idxAbove]))) tau/101325*10^6
December 5, 2006 at 1:56 am #8811Dirk KampffmeyerParticipantHello,
first of all I would like to thank you. Now I have a last request: I would like to search the maximum of the signal and let the program sum it up from this maximum.
dim tau = ch1.y/2*130-110
Dim idxAbove = ValuesAboveLevel(tau, 0, EVENT_INDEX)
Dim idxBelow = IndexNot(idxAbove, NumberOfRows(ch1))
tau[idxBelow] = 611.15*exp(22.542*tau[idxBelow]/(tau[idxBelow]+273.48))
tau[idxAbove] = 611.21*exp(17.502*tau[idxAbove]/(240.97+tau[idxAbove]))
tau/101325*10^6December 5, 2006 at 2:43 am #8812Bernhard KantzParticipantYou can use the Maximum-function to calculate the maximum of the signal. You find all FPScript functions in the function wizard.
See also the FlexPro Online Help.
-
AuthorPosts
- You must be logged in to reply to this topic.