please help with my code
3 views (last 30 days)
Show older comments
Im trying to use kalman filters
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,[] ,'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];
c = [C;C];
d = [0 0 0;0 0 1];
P = ss(a,b,c,d,-1,'inputname',{'u' 'w' 'v'},'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 3],[1 2 3]); % Delete yv from I/O list
SimModel.InputName;
SimModel.OutputName;
src = dsp.SignalSource('SamplesPerFrame',5600);
src.Signal = xlsread('D:\ieee14\trainingset.xlsx',1,'A1:AB5601');
u = src.Signal;
src1 = dsp.SignalSource('SamplesPerFrame',5600);
src1.Signal = xlsread('D:\ieee14\faultset.xlsx',1,'A1:AB5601');
w = src1.Signal;
src2 = dsp.SignalSource('SamplesPerFrame',5600);
src2.Signal = xlsread('D:\ieee14\faultset.xlsx',1,'A5601:AB11201');
v = src2.Signal;
%T = horzcat[w,v,u,...];
%D = vertcat(u,v,w);
[out,x] = lsim(SimModel,[],[w,v,u]);
% sine1 = dsp.SineWave('spf',5600);
% sine1.Signal = xlsread('D:\ieee14\faultset.xlsx',1,'A1:N5601'), 10,xlsread('D:\ieee14\faultset.xlsx',1,'O1:AB5601');
% src = dsp.SignalSource(xlsread('D:\ieee14\faultset.xlsx',1,'A5601:AB11201'));
% %src.Signal = xlsread('D:\ieee14\faultset.xlsx',1,'A5601:AB11201');
%
i keep getting this error , how can i remove it?
Error using horzcat
Dimensions of matrices being concatenated are not consistent.
i have attached my input files as pictures as the files are too big to upload ; input image is a dataset with stable and unstable system voltage and phase (vtg is from A:N and phase from O:AB) and the input image is an excel sheet with 5600 fault values and 5601:16801 are the normal stable system values
input2 image is the values to be tested and using kalman to find how close they are to the dataset
Thanks in advance
I also wanted to keep u to be a input like
src = dsp.SignalSource('SamplesPerFrame',1);
src.Signal = xlsread('D:\ieee14\trainingset.xlsx',1,'A1:AB1');
u = src.Signal;
but as it shows this error
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 kalman15thapril (line 36)
[out,x] = lsim(SimModel,[w,v]);
18 Comments
Walter Roberson
on 18 Apr 2017
I am not sure if I understand your question, but it seems to me you could extract appropriate columns from your input. For example,
U3 = [w(:,4), v(:,4), u(:,21)];
[out,x] = lsim(SimModel, U3, []);
Answers (0)
See Also
Categories
Find more on Time and Frequency Domain Analysis in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!