Results 1 to 2 of 2

Thread: Live Plotting the data from 2D QVector of type QPointF

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2017
    Posts
    6
    Thanks
    2
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Live Plotting the data from 2D QVector of type QPointF

    Using sources online I have managed to live plot 4 graphs of sensor values over time, however I want to use the values from the sensors to plot a live plot a 5th plot using the values from the previous plots. The variable sampleVector is a 2D array containing sensory values (Y-variable) over time (X-variable)

    The formula for the 5th plot is: Plot5= -0.5 * (Plot0 + Plot1) ... over all the samples

    Below is my attempt at achieving this, however it did not work. The 5th plot seemed to plot twice as fast like it was appending twice as many x-values. It also did not seem to like me multiplying a value such as "-0.5". I am new to Qt and I haven't found a way to manipulate and use the Y-values of "sampleVector". I don't quite understand the format of the variable either if that can be explained as well please.

    Thank you in advance, please Help I am desperate.

    Qt Code:
    1. void Plot::plotSampleVector(QVector<QVector<QPointF> > sampleVector){
    2.  
    3. //*** length of the data
    4. const int sampleSize = sampleVector.length();
    5.  
    6. //***Append new values to "QVector<Plot *> d_plots"
    7. for (int ii=0; ii< sampleSize; i++){
    8.  
    9. d_plots[0] -> AppendPoint(sampleVector.at(ii).at(0));
    10. d_plots[1] -> AppendPoint(sampleVector.at(ii).at(1));
    11. d_plots[2] -> AppendPoint(sampleVector.at(ii).at(2));
    12. d_plots[3] -> AppendPoint(sampleVector.at(ii).at(3));
    13. // Problem Code:
    14. d_plots[4] -> AppendPoint(-0.5 * (sampleVector.at(ii).at(0) + sampleVector.at(ii).at(1)));
    15.  
    16. }
    17.  
    18. //***Draw Curves
    19. for (int ii=0; ii<5; ii++){
    20. d_plots[ii] ->DrawCurveSegment(sampleSize)
    21. }
    22.  
    23. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by VitaminG; 12th January 2017 at 14:00.

Similar Threads

  1. Replies: 9
    Last Post: 27th March 2014, 09:45
  2. Replies: 2
    Last Post: 27th November 2013, 00:56
  3. QT 4.5 and Plotting data
    By Lezer in forum Qt for Embedded and Mobile
    Replies: 3
    Last Post: 6th September 2012, 13:11
  4. Replies: 5
    Last Post: 2nd September 2011, 23:11
  5. Live Update data in table
    By abghosh in forum Qt Programming
    Replies: 8
    Last Post: 25th February 2010, 18:16

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.