i need to filter this ode45 sine wave becomes a smooth one...
Ältere Kommentare anzeigen
i used this line of code, and i implement Lowpass FIR filter, but maybe the code i used is wrong somewhere. can anybody help me fixed this
error popped is 'Index exceeds Matrix dimension' and 'Error using forced (line 2),Not enough input arguments.'
these are the codes
EDITOR: function dxdt = forced(t,x) dxdt_1 = x(2); dxdt_2 = -100*x(2)-250000*x(1)+ ((25000)*((0.00002)*sin(2.6735*t))^3); dxdt = [dxdt_1;dxdt_2];
COMMAND WINDOW: tspan=[0:0.1:20]; initial_x=0; initial_dxdt=0; [t,x]=ode45(@forced,tspan,[initial_x initial_dxdt]); figure plot(t,x(:,1)); grid on %UNTIL HERE IT WORKS FINE
fHandle=@forced; Fs=20; fc=3; t=linspace(0,0.1,Fs); Wn=(2/Fs)*fc; b=fir1(20,Wn,'low',kaiser(21,3)); fvtool(b,1,'Fs',Fs)
z=filter(b,1,fHandle());
plot(t(1:100),fHandle()(1:100)) hold on plot(t(1:100,z(1:100)) xlabel('Time(s)') ylabel('Amplitude') legend('Original Signal','Filtered Data') %the error appear here...
any suggestion or helps, much thanks.
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Signal Generation, Analysis, and Preprocessing finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!