Skip to content

Instantly share code, notes, and snippets.

@GiovanniBalestrieri
Last active August 29, 2015 14:26
Show Gist options
  • Select an option

  • Save GiovanniBalestrieri/2077455ba01d703bbd4a to your computer and use it in GitHub Desktop.

Select an option

Save GiovanniBalestrieri/2077455ba01d703bbd4a to your computer and use it in GitHub Desktop.
Snippet - Basic Filter Matlab
%% Real Signal definition
% Sampling Frequency Fs
Fs = 350;
% Sinusoid frequency
freq = 30;
bias = 1
maxTime = 2;
t = 0:1/Fs:maxTime;
% Generate random values [min,max] = [xm,xM]
xm = -0.1;
xM = 0.1;
amp = xm+ (xM-xm).*rand(1,Fs*maxTime+1);
% Use random value for the amplitude
y = bias + amp;
y0 = 0;
ybias = bias;
y2 = 2;
% Plots raw data vs samples
figure(1);
plot(t,y);
hold on
plot(t,y0,'k','LineWidth',2);
hold on
plot(t,y2,'k');
hold on
plot(t,ybias,'r');
title('Sinusoid');
xlabel('Time [s]');
ylabel('Amplitude of f');
grid on
grid minor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment