Filtering a signal developed from a Lagrangian
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi Guys
I have attached a portion of a solution which I have developed by solving a set of differential equations.
Variable "a" presents the correct solution while "b" needs to be filtered.
The results are expected to be very similar if not identical.
The below code presents the filtering which I performed on the results. Note that the code does not call up the attached excel spread sheet with the results as the results are already stored in in variable "b".
Variable "inc" has a value of 0.001, which is the increment used for the ode45 solver.
Can anyone please provide me with some feedback on what I am doing wrong?
b = y(:,7);
Fs = 1/inc;
Fc = 1/(Fs/2); %cut off frequency
[b1 a1] = butter(4,Fc,'high');
b = detrend(b,1);
b = filtfilt(b1,a1,b);
figure(1)
hold on
plot(t,a);
plot(t,b);
2 Kommentare
Mathieu NOE
am 14 Okt. 2021
hello
there is nothing wrong with the code in the post , but I wonder why your solution (b) is so far off from the "true" one (a)
while a is a sine wave , b seems more like the transient response of your system. Did you simulate your system long enough so that the b solution is "steady state" ?
T = readtable('data1.xlsx');
t = T.time;
a = T.a;
b = T.b;
inc = 1e-3;
Fs = 1/inc;
Fc = 1/(Fs/2); %cut off frequency
[b1, a1] = butter(4,Fc,'high');
b = detrend(b,1);
bb = filtfilt(b1,a1,b);
figure(1)
subplot(211),plot(t,a,'k');
legend('a');
subplot(212),plot(t,b,'b',t,bb,'r');
% ylim([-1 1]);
legend('b','bb');
Antworten (0)
Siehe auch
Kategorien
Mehr zu Ordinary Differential Equations 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!