Click here to Skip to main content
16,016,814 members
Home / Discussions / C#
   

C#

 
AnswerRe: Implementing a moving average Pin
Ralf Meier15-Feb-18 21:27
mveRalf Meier15-Feb-18 21:27 
GeneralRe: Implementing a moving average Pin
auting8216-Feb-18 1:25
auting8216-Feb-18 1:25 
GeneralRe: Implementing a moving average Pin
Pete O'Hanlon16-Feb-18 7:53
mvePete O'Hanlon16-Feb-18 7:53 
GeneralRe: Implementing a moving average Pin
Ralf Meier16-Feb-18 9:49
mveRalf Meier16-Feb-18 9:49 
GeneralRe: Implementing a moving average Pin
auting8216-Feb-18 11:40
auting8216-Feb-18 11:40 
GeneralRe: Implementing a moving average Pin
Ralf Meier16-Feb-18 12:42
mveRalf Meier16-Feb-18 12:42 
GeneralRe: Implementing a moving average Pin
Ralf Meier17-Feb-18 0:14
mveRalf Meier17-Feb-18 0:14 
GeneralRe: Implementing a moving average Pin
auting8217-Feb-18 0:36
auting8217-Feb-18 0:36 
Hi again Ralf and thanks for the patience. I understood what OG's method does in terms of the result I got. My problem is now how do I make this list to store my numbers that get generated by the GetAnalog Method.
I would need to have historical analog values for each Sensor and then apply OG's method on each sensor array or list , whatever is made.

Here is the GetAnalogMethod() from the Sensor.cs class,

C#
public double GetAnalogValue(double minAnalogVolt=0.00F,double maxAnalogVolt=1.00F) 
        {
            if(minAnalogVolt <= AnalogVal && AnalogVal<= maxAnalogVolt) //defines measurement interval for sensor

                 AnalogVal = rSensVal.NextDouble(); //generates values between 0-1
                 return AnalogVal; //return a value        
        }


In here I call this GetAnalogValue() method to generate "random" analog values for each of my sensor IDs:
C#
for (int id = 0; id < maxAI; id++)
            {
                double AnalogSensorValues = sObj[id].GetAnalogValue(); //for loops runs through the loop and inserts random number between 0-1 for each sensors ID
                sTxt = AnalogSensorValues.ToString("F3");//defines a string variable in order to print out sensor values
                textSensorValues.Text += sTxt + "    ";//prints out sesnor values in text box 
                txtFilterValues.Text = fTx1;//defines a string variable for moving average filtered values
                txtFilterValues.Text = GetMovingAverage(AnalogSensorValues).ToString("F3");//applies GetMoving Average method and prints the last fuive values in the textbox
            }


If you see above I store all my sensor ID values in a double variable I call AnalogSensorValues.I should have ideally have had a list so that each value gets stored and can be accessed so that GetMoving Average() method can be applied to it.

So yes, that is my problem. Basically sorting these values in a List. This may sound silly, but I don't know how to do it Unsure | :~

modified 17-Feb-18 6:42am.

AnswerRe: Implementing a moving average Pin
Ralf Meier17-Feb-18 0:53
mveRalf Meier17-Feb-18 0:53 
GeneralRe: Implementing a moving average Pin
auting8217-Feb-18 1:13
auting8217-Feb-18 1:13 
GeneralRe: Implementing a moving average Pin
Ralf Meier17-Feb-18 3:30
mveRalf Meier17-Feb-18 3:30 
AnswerRe: Implementing a moving average Pin
Ralf Meier17-Feb-18 3:50
mveRalf Meier17-Feb-18 3:50 
GeneralRe: Implementing a moving average Pin
auting8217-Feb-18 7:40
auting8217-Feb-18 7:40 
GeneralRe: Implementing a moving average Pin
Ralf Meier17-Feb-18 10:11
mveRalf Meier17-Feb-18 10:11 
GeneralRe: Implementing a moving average Pin
auting8218-Feb-18 8:40
auting8218-Feb-18 8:40 
GeneralRe: Implementing a moving average Pin
Ralf Meier18-Feb-18 9:32
mveRalf Meier18-Feb-18 9:32 
GeneralRe: Implementing a moving average Pin
auting8227-Feb-18 21:33
auting8227-Feb-18 21:33 
AnswerRe: Implementing a moving average Pin
Gerry Schmitz15-Feb-18 8:16
mveGerry Schmitz15-Feb-18 8:16 
Question.NET - choose correct service for conversion Pin
Bulgarin14-Feb-18 4:54
Bulgarin14-Feb-18 4:54 
AnswerRe: .NET - choose correct service for conversion Pin
Gerry Schmitz14-Feb-18 6:40
mveGerry Schmitz14-Feb-18 6:40 
Questioncreating trial version and expiry date issue Pin
Mou_kol14-Feb-18 0:30
Mou_kol14-Feb-18 0:30 
AnswerRe: creating trial version and expiry date issue Pin
Pete O'Hanlon14-Feb-18 0:38
mvePete O'Hanlon14-Feb-18 0:38 
GeneralRe: creating trial version and expiry date issue Pin
Mou_kol15-Feb-18 21:16
Mou_kol15-Feb-18 21:16 
AnswerRe: creating trial version and expiry date issue Pin
Eddy Vluggen14-Feb-18 3:22
professionalEddy Vluggen14-Feb-18 3:22 
AnswerRe: creating trial version and expiry date issue Pin
OriginalGriff14-Feb-18 4:30
mveOriginalGriff14-Feb-18 4:30 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.