DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Querying Without a Query Language
  • Tableau Dashboard Development Best Practices
  • An Introduction to Bloom Filters
  • Motivations for Creating Filter and Merge Plugins for Apache JMeter With Use Cases

Trending

  • YOLOv5 PyTorch Tutorial
  • Java String Format Examples
  • Real-Time AI Inference at Scale Using Cloud Run, GPUs, and Vertex AI
  • How to Set Up and Run PostgreSQL Change Data Capture

Simple Kalman Filter in C

This code snippet covers simple Kalman filters in C.

By 
Snippets Manager user avatar
Snippets Manager
·
May. 01, 10 · Code Snippet
Likes (4)
Comment
Save
Tweet
Share
13.4K Views

Join the DZone community and get the full member experience.

Join For Free
/** A simple kalman filter example by Adrian Boeing 
 www.adrianboeing.com 
 */ 

#include 
#include 
#include 

double frand() {
    return 2*((rand()/(double)RAND_MAX) - 0.5);
}

int main() {

    //initial values for the kalman filter
    float x_est_last = 0;
    float P_last = 0;
    //the noise in the system
    float Q = 0.022;
    float R = 0.617;

    float K;
    float P;
    float P_temp;
    float x_temp_est;
    float x_est;
    float z_measured; //the 'noisy' value we measured
    float z_real = 0.5; //the ideal value we wish to measure

    srand(0);

    //initialize with a measurement
    x_est_last = z_real + frand()*0.09;

    float sum_error_kalman = 0;
    float sum_error_measure = 0;

    for (int i=0;i
Filter (software)

Opinions expressed by DZone contributors are their own.

Related

  • Querying Without a Query Language
  • Tableau Dashboard Development Best Practices
  • An Introduction to Bloom Filters
  • Motivations for Creating Filter and Merge Plugins for Apache JMeter With Use Cases

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook