-
-
Save GiovanniBalestrieri/2077455ba01d703bbd4a to your computer and use it in GitHub Desktop.
Snippet - Basic Filter Matlab
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| %% 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