Skip to content

Instantly share code, notes, and snippets.

@GiovanniBalestrieri
Created August 3, 2015 21:25
Show Gist options
  • Save GiovanniBalestrieri/93feee1b637103e5b7e8 to your computer and use it in GitHub Desktop.
Save GiovanniBalestrieri/93feee1b637103e5b7e8 to your computer and use it in GitHub Desktop.
snippet - Basic Matlab Filter
%% Signal definition
% Sampling Frequency Fs
Fs = 350;
% Sinusoid frequency
freq = 30;
bias = 15
t = 0:1/Fs:1;
% Generate random values [min,max] = [xm,xM]
xm=0.2;
xM=2;
amp = xm+ (xM-xm).*rand(1,1);
% Use random value for the amplitude
y = amp*sin(2*pi*freq*t) + bias;
y0 = 0;
y18 = 18;
% Plots raw data vs samples
figure(1);
plot(t,y);
hold on
plot(t,y0,'r','LineWidth',2);
hold on
plot(t,y18,'k');
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