Filter löschen
Filter löschen

Filtering a signal developed from a Lagrangian

3 Ansichten (letzte 30 Tage)
Mishal Mohanlal
Mishal Mohanlal am 14 Okt. 2021
Kommentiert: Mishal Mohanlal am 14 Okt. 2021
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
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');
Mishal Mohanlal
Mishal Mohanlal am 14 Okt. 2021
Hi Mathieu
Yes I have.
The system consists of two elastic pendulums connected at their ends by a rigid bar. There is a holonomic constraint which I developed so that the mass always stay a certain distance apart.
The part of the solution which has the holonomic constraint substituted in (b) develops poor solutions.
There are numerous imaginary numbers which I also developed, I assume these concern themselves with a a reflection of the real portion...

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Produkte


Version

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by