Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Extended Kalman Filter

Subject: Extended Kalman Filter

From: harun

Date: 17 Dec, 2009 10:57:03

Message: 1 of 2

Hi dear....,

I want to estimate moving object by using extended kalman filter.
this code is for kalman filter.. and its also works as not bad

now in this code, when I want to change it to Extended kalman filter, I have to use two functions one of them is f and the other is h function. my problem is how to define these function??
the moving object is not specific object... it may be a plane.

function kalman()
clear,clc
...
...
...
% Kalman filter initialization
R=[[0.2845,0.0045]',[0.0045,0.0455]'];
H=[[1,0]',[0,1]',[0,0]',[0,0]'];
Q=0.01*eye(4);
P = 100*eye(4);
dt=1;
A=[[1,0,0,0]',[0,1,0,0]',[dt,0,1,0]',[0,dt,0,1]'];
g = 6; % pixels^2/time step
Bu = [0,0,0,g]';
kfinit=0;
x=zeros(100,4);

% loop over all images
for i = 1 : 30
...
...
...
  %extract background
  [cc(i),cr(i),radius,flag] = extractbackgraund(Imwork,Imback,i);
  if flag==0
    continue
  end
  imshow(Im);
  hold on
    for c = -1*radius: radius/20 : 1*radius
      r = sqrt(radius^2-c^2);
      plot(cc(i)+c,cr(i)+r,'g.')
      plot(cc(i)+c,cr(i)-r,'g.')
    end
  % Kalman update

  if kfinit==0
    xp = [MC/2,MR/2,0,0]'
  else
    xp=A*x(i-1,:)' + Bu %this code is for kalman iflter

    %X(k|k-1)=fonktion f(x(i,:),Bu) % extended kalman filter should be
    
  end
  kfinit=1;
  PP = A*P*A' + Q

  % P(k|k-1)=Fk*P(k-1|k-1)*Fk'+Q(k-1) %predicted estimate covariance

  K = PP*H'*inv(H*PP*H'+R)
  x(i,:) = (xp + K*([cc(i),cr(i)]' - H*xp))';
  %Zk=[cc(i),cr(i)]'
  x(i,:)
  [cc(i),cr(i)]
  P = (eye(4)-K*H)*PP %updated estiamte covariance
hold on
    for c = -1*radius: radius/20 : 1*radius
      r = sqrt(radius^2-c^2);
       plot(cc(i)+c,cr(i)+r,'g.')
      plot(cc(i)+c,cr(i)-r,'g.')
    end
end

% show positions
  figure
  plot(cc,'r*')
  hold on
  plot(cr,'g*')
%end
stop(vid);
%estimate image noise (R) from stationary ball
  posn = [cc(55:60)',cr(55:60)'];
  mp = mean(posn);
  diffp = posn - ones(6,1)*mp;
  Rnew = (diffp'*diffp)/5;
  

Subject: Extended Kalman Filter

From: Michael_RW

Date: 22 Jan, 2010 04:31:55

Message: 2 of 2


Hey, Love:

Do you know what the functions "f" and "h" are?


Michael.




---
frmsrcurl: http://compgroups.net/comp.soft-sys.matlab/Extended-Kalman-Filter

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us