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.
void Plot::plotSampleVector(QVector<QVector<QPointF> > sampleVector){
//*** length of the data
const int sampleSize = sampleVector.length();
//***Append new values to "QVector<Plot *> d_plots"
for (int ii=0; ii< sampleSize; i++){
d_plots[0] -> AppendPoint(sampleVector.at(ii).at(0));
d_plots[1] -> AppendPoint(sampleVector.at(ii).at(1));
d_plots[2] -> AppendPoint(sampleVector.at(ii).at(2));
d_plots[3] -> AppendPoint(sampleVector.at(ii).at(3));
// Problem Code:
d_plots[4] -> AppendPoint(-0.5 * (sampleVector.at(ii).at(0) + sampleVector.at(ii).at(1)));
}
//***Draw Curves
for (int ii=0; ii<5; ii++){
d_plots[ii] ->DrawCurveSegment(sampleSize)
}
}
void Plot::plotSampleVector(QVector<QVector<QPointF> > sampleVector){
//*** length of the data
const int sampleSize = sampleVector.length();
//***Append new values to "QVector<Plot *> d_plots"
for (int ii=0; ii< sampleSize; i++){
d_plots[0] -> AppendPoint(sampleVector.at(ii).at(0));
d_plots[1] -> AppendPoint(sampleVector.at(ii).at(1));
d_plots[2] -> AppendPoint(sampleVector.at(ii).at(2));
d_plots[3] -> AppendPoint(sampleVector.at(ii).at(3));
// Problem Code:
d_plots[4] -> AppendPoint(-0.5 * (sampleVector.at(ii).at(0) + sampleVector.at(ii).at(1)));
}
//***Draw Curves
for (int ii=0; ii<5; ii++){
d_plots[ii] ->DrawCurveSegment(sampleSize)
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks