Ibaghdadi
Newbie level 6
levanon matlab code
Hi iam wrinting a simple Matlab code that generates a sinusoidal signal which is then sampled ploted. when I take the sampling frequency fs=5000 and f0=4500 hz. The number of samples n=100,.
I should get an aliaisnig error right because fs<2*f0.... The problem is that i get all the signal undistorted!!! This is the Matlab code:
Hi iam wrinting a simple Matlab code that generates a sinusoidal signal which is then sampled ploted. when I take the sampling frequency fs=5000 and f0=4500 hz. The number of samples n=100,.
I should get an aliaisnig error right because fs<2*f0.... The problem is that i get all the signal undistorted!!! This is the Matlab code:
Code:
function [x,t]=sin_gen(f0,fs,N)
N=input('input the value N\n');%N=100
f0=input('input f0\n');
fs=input('input the value fs\n');%fs=5000
n=0:N-1;
x=sin(2*pi*n*(f0/fs));
Ts=1/fs;
t=n*Ts;
stem(t,x,'r');
xlabel('t');
ylabel('x[n]');