FlexPro
HistoryBase
Ingénierie
Formation
Téléchargements
Assistance FlexPro
Connaissance
Communauté
À propos de nous
Références
Emplois
Contact général
Liste des revendeurs
Assistance FlexPro
FR
DE
EN
Porte-plaquette
Produits et solutions
Support et téléchargements
Entreprise
Magazine
Contact
Langue
MyWeisang

Paramètres du compte.

Topic

Division durch Null

Page d'accueil ' Communauté ' FPScript ' Division par zéro

Voir les messages de 6 - 1 à 6 (sur un total de 6)
  • Auteur
    Messages
  • #33316
    Martin Uellenberg
    Participant

    Hallo,

    ich möchte die y-Werte von zwei Signalen (Signal1 und Signal2) durcheinander dividieren. Sobald der Wert des Divisors = 0 ist, bekomme ich natürlich eine Fehlermeldung (Division durch Null). Wie kann ich mit FPScript dafür sorgen, dass bei einer Division durch Null eine Null als Ergebnis hinterlegt wird ?

    Danke und Gruß
    Ulli

    #33321
    Martin Uellenberg
    Participant

    Hallo,

    ich möchte die y-Werte von zwei Signalen (Signal1 und Signal2) durcheinander dividieren. Sobald der Wert des Divisors = 0 ist, bekomme ich natürlich eine Fehlermeldung (Division durch Null). Wie kann ich mit FPScript dafür sorgen, dass bei einer Division durch Null eine Null als Ergebnis hinterlegt wird ?

    Danke und Gruß
    Ulli

    #33317
    Bernhard Kantz
    Participant

    In this case you can use the [b]Try…Catch…End[/b] statement.

    Example:
    [code]
    Dim a, b
    a = 1.
    b = 0
    Try
    return a/b
    Catch Exception
    return ?
    End
    [/code]

    support@weisang.com

    #33318
    Martin Uellenberg
    Participant

    Hallo,

    danke für die Antwort. Leider komme ich damit noch nicht zurecht. Nochmal mein Problem. Ich möchte zwei Signale (Signal1 und Signal2) durcheinander dividieren. An den Stellen, wo eine Division durch Null stattfindet, soll eine Null als Ergebnis raus kommen. Mit oben angegebener Lösung bekomme ich immer nur einen Wert als Ergebnis. Nicht aber einen neuen Datensatz (mit gleicher Werteanzahl wie Signal1 und Signal2).

    Wie sieht die Formel dafür aus ?

    Danke und Gruß
    Martin

    #33319
    Bernhard Kantz
    Participant

    There is a difference if the Y component of the signal contains integer or floating point values. If the signal contains integer values an exception will be thrown in case of a division by zero (see sample above).
    With floating point values no exception is thrown, but the result will contain an invalid value (?) at the places where a division by zero occured.
    The different behavior stems from the fact that there is no possibility to express an invalid value with integer values.

    This what you have to do: Execute the division as usual. Search and replace the invalid values by 0 afterwards:
    [code]
    dim a, b, c

    a = { 1., 2., 3., 4., 5., 6. }
    b = { 3, 0, 2, 0, 11, 0 }
    c = a / b
    c[SearchVoidValues(c)] = 0
    [/code]
    Support
    support@weisang.com

    #33320
    Martin Uellenberg
    Participant

    Vielen Dank. So funktioniert es.

Voir les messages de 6 - 1 à 6 (sur un total de 6)
  • Vous devez être connecté pour répondre à ce sujet.