how to implement kalman filter function?
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
we are working on a code that requires to merge the measured value with the true value of the dataset using kalman filter. Below is the code that we are working on and having errors in T.
A = [1.1269 -0.4940 0.1129;
1.0000 0 0;
0 1.0000 0];
B = [-0.3832;
0.5919;
0.5191];
C = [1 0 0];
Plant = ss(A,[B B],C,0,-1,'inputname',{'u' 'w'},'outputname','y');
Q = 1;
R = 1;
[kalmf,L,P,M] = kalman(Plant,Q,R);
M;
kalmf = kalmf(1,:);
a = A;
b = [B B 0*B B B 0*B B B 0*B B B 0*B B B 0*B B B 0*B B B 0*B B B 0*B B B 0*B 0*B];
c = [C;C];
d = [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1];
P = ss(a,b,c,d,-1,'inputname',{'u' 'w' 'v' 'a1' 'a2' 'a3' 'a4' 'a5' 'a6' 'a7' 'a8' 'a9' 'b1' 'b2' 'b3' 'b4' 'b5' 'b6' 'b7' 'b8' 'b9' 'c1' 'c2' 'c3' 'c4' 'c5' 'c6' 'c7'},'outputname',{'y' 'yv'});
sys = parallel(P,kalmf,1,1,[],[]);
SimModel = feedback(sys,1,4,2,1); % Close loop around input #4 and output #2
SimModel = SimModel([1 2],[28 1 2]); % Delete yv from I/O list
SimModel.InputName;
SimModel.OutputName;
m = cell(1,28);
t=zeros(size(m,1),size(m,2));
t=str2double(m);
src = dsp.SignalSource('SamplesPerFrame',1);
src.Signal = xlsread('D:\ieee14\trainingset.xlsx',1,'A1:AB1');
w = src.Signal;
src1 = dsp.SignalSource('SamplesPerFrame',5600);
src1.Signal = xlsread('D:\ieee14\faultset.xlsx',1,'A1:AB5601');
u = src1.Signal;
src2 = dsp.SignalSource('SamplesPerFrame',5600);
src2.Signal = xlsread('D:\ieee14\faultset.xlsx',1,'A5601:AB11201');
v = src2.Signal;
[out,x] = lsim(SimModel,[u;v;w]);
the error is
Error using DynamicSystem/lsim (line 84)
When simulating the response to a specific input signal, the input data U must be a matrix with as many rows as samples in the time
vector T, and as many columns as input channels.
Error in kalman16thapril (line 42)
[out,x] = lsim(SimModel,[w;v;u]);
size of u is 5601x28
v is 5601x28
w is 1x28
t is 1x28
sys is 3x29 %i ddnt set this one it came on its own
1 Kommentar
John D'Errico
am 19 Apr. 2017
First, read this. Learn how to format your code so it is readable, instead of the mess you have given us.
https://www.mathworks.com/matlabcentral/answers/13205-tutorial-how-to-format-your-question-with-markup#answer_18099
Next, what errors? If you have an error, then show it.
Antworten (0)
Siehe auch
Kategorien
Mehr zu PID Controller Tuning finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!