Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Correcting data by equation parameters
Forum Updated to NodeBB v4.3 + New Features

Correcting data by equation parameters

Scheduled Pinned Locked Moved Unsolved General and Desktop
22 Posts 4 Posters 5.5k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    erytcg
    wrote on 19 Oct 2017, 19:48 last edited by erytcg
    #1

    Hello I have some data in my program and I want correct it.
    For example:
    x = 1,012;

    I need command line where I could enter some like this:

    x=0.98*x+0.1;
    or like this
    x=(1.3x+1)^2;

    with the mathematic sequence of actions

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 19 Oct 2017, 19:51 last edited by
      #2

      Hi,

      What do you mean by "command line" ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • E Offline
        E Offline
        erytcg
        wrote on 19 Oct 2017, 19:57 last edited by
        #3

        Maybe QLineEdit it doesn't matter, widget to input String.

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 19 Oct 2017, 20:02 last edited by SGaist
          #4

          Are you looking to implement something like SpeedCrunch ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • E Offline
            E Offline
            erytcg
            wrote on 21 Oct 2017, 12:14 last edited by
            #5

            I need something simple. Maybe only y=ax+b;

            M 1 Reply Last reply 21 Oct 2017, 19:39
            0
            • E erytcg
              21 Oct 2017, 12:14

              I need something simple. Maybe only y=ax+b;

              M Offline
              M Offline
              mrjj
              Lifetime Qt Champion
              wrote on 21 Oct 2017, 19:39 last edited by
              #6

              @erytcg
              and you want to parse it and execute it ?
              There are many examples of a small calculator on the net. its a common
              text book task.

              1 Reply Last reply
              2
              • V Offline
                V Offline
                VRonin
                wrote on 23 Oct 2017, 08:10 last edited by
                #7

                https://en.wikipedia.org/wiki/Shunting-yard_algorithm

                "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
                ~Napoleon Bonaparte

                On a crusade to banish setIndexWidget() from the holy land of Qt

                1 Reply Last reply
                2
                • E Offline
                  E Offline
                  erytcg
                  wrote on 23 Oct 2017, 17:17 last edited by
                  #8

                  any example for calculating without buttons? only input line.

                  M 1 Reply Last reply 23 Oct 2017, 17:18
                  0
                  • E erytcg
                    23 Oct 2017, 17:17

                    any example for calculating without buttons? only input line.

                    M Offline
                    M Offline
                    mrjj
                    Lifetime Qt Champion
                    wrote on 23 Oct 2017, 17:18 last edited by
                    #9

                    @erytcg
                    The link VRonin gave is without buttons.
                    Just the pure way to do it.

                    1 Reply Last reply
                    1
                    • E Offline
                      E Offline
                      erytcg
                      wrote on 23 Oct 2017, 17:33 last edited by
                      #10

                      It is possible to use varibales names in this?

                      M 1 Reply Last reply 23 Oct 2017, 17:36
                      0
                      • E erytcg
                        23 Oct 2017, 17:33

                        It is possible to use varibales names in this?

                        M Offline
                        M Offline
                        mrjj
                        Lifetime Qt Champion
                        wrote on 23 Oct 2017, 17:36 last edited by mrjj
                        #11

                        @erytcg
                        yeah should be as you can just treat the variable as a number and substitute when you calculate the result.
                        it also support operator precedence but stuff like
                        x=(1.3x+1)^2;
                        will require somewhat a more data complex model to handle flawless i think.

                        1 Reply Last reply
                        0
                        • E Offline
                          E Offline
                          erytcg
                          wrote on 23 Oct 2017, 17:42 last edited by
                          #12

                          And one more question this algorithm is fast? I have a looot of data and I have to calculate it in real time:D

                          M 1 Reply Last reply 23 Oct 2017, 17:49
                          0
                          • E erytcg
                            23 Oct 2017, 17:42

                            And one more question this algorithm is fast? I have a looot of data and I have to calculate it in real time:D

                            M Offline
                            M Offline
                            mrjj
                            Lifetime Qt Champion
                            wrote on 23 Oct 2017, 17:49 last edited by
                            #13

                            @erytcg
                            well, it's minimal and makes handling the expressions easier (for the programmer) but since it is sort of a text parser, not that fast but for small expressions its not wildly time consuming.

                            1 Reply Last reply
                            0
                            • M Offline
                              M Offline
                              mrjj
                              Lifetime Qt Champion
                              wrote on 23 Oct 2017, 17:51 last edited by
                              #14

                              Depending on what you need to handle, maybe using something like
                              https://github.com/ArashPartow/exprtk ?

                              1 Reply Last reply
                              0
                              • E Offline
                                E Offline
                                erytcg
                                wrote on 29 Oct 2017, 19:23 last edited by erytcg
                                #15

                                Can I use QScriptEngine?

                                But I have problem

                                #include <QtScript/qscriptengine.h>
                                #include <QtScript/qscriptvalue.h>
                                
                                QString x = ui->correctDataLine->displayText();
                                QScriptEngine myEngine;
                                QScriptValue x2 = myEngine.evaluate(x);
                                qDebug() << x2.toNumber();
                                
                                undefined reference to `_imp___ZN13QScriptEngineC1Ev'
                                
                                M 1 Reply Last reply 29 Oct 2017, 19:50
                                0
                                • E erytcg
                                  29 Oct 2017, 19:23

                                  Can I use QScriptEngine?

                                  But I have problem

                                  #include <QtScript/qscriptengine.h>
                                  #include <QtScript/qscriptvalue.h>
                                  
                                  QString x = ui->correctDataLine->displayText();
                                  QScriptEngine myEngine;
                                  QScriptValue x2 = myEngine.evaluate(x);
                                  qDebug() << x2.toNumber();
                                  
                                  undefined reference to `_imp___ZN13QScriptEngineC1Ev'
                                  
                                  M Offline
                                  M Offline
                                  mrjj
                                  Lifetime Qt Champion
                                  wrote on 29 Oct 2017, 19:50 last edited by mrjj
                                  #16

                                  @erytcg
                                  do you have
                                  QT += script
                                  in the pro file?

                                  1 Reply Last reply
                                  3
                                  • E Offline
                                    E Offline
                                    erytcg
                                    wrote on 29 Oct 2017, 19:56 last edited by
                                    #17

                                    Ok thanks my bad:(
                                    Do you think can I use this with variables names?

                                    M 1 Reply Last reply 29 Oct 2017, 19:59
                                    1
                                    • E erytcg
                                      29 Oct 2017, 19:56

                                      Ok thanks my bad:(
                                      Do you think can I use this with variables names?

                                      M Offline
                                      M Offline
                                      mrjj
                                      Lifetime Qt Champion
                                      wrote on 29 Oct 2017, 19:59 last edited by
                                      #18

                                      @erytcg
                                      What do you mean with "variables names" ?
                                      To put inside QScriptEngine or what you wanna do with variables?

                                      1 Reply Last reply
                                      0
                                      • M Offline
                                        M Offline
                                        mrjj
                                        Lifetime Qt Champion
                                        wrote on 29 Oct 2017, 20:02 last edited by mrjj
                                        #19

                                        Ah I see where you are aiming :)
                                        Yes you can use it for your use case. Depending on the complexity you need.
                                        http://www.informit.com/articles/article.aspx?p=1405559&seqNum=2
                                        Using script with js to play calculator.

                                        1 Reply Last reply
                                        0
                                        • E Offline
                                          E Offline
                                          erytcg
                                          wrote on 29 Oct 2017, 20:19 last edited by
                                          #20

                                          I have this
                                          0_1509308181416_1a4c9133-55ab-43be-9958-7c649b4c8d49-obraz.png

                                          And I have variable name: x. I put to QLineEdit 1+x * 3
                                          And script automatically calculate new value of x.
                                          x = 1+x*3

                                          M 1 Reply Last reply 29 Oct 2017, 20:22
                                          0

                                          1/22

                                          19 Oct 2017, 19:48

                                          • Login

                                          • Login or register to search.
                                          1 out of 22
                                          • First post
                                            1/22
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • Users
                                          • Groups
                                          • Search
                                          • Get Qt Extensions
                                          • Unsolved