I studied the following for forming a pulse train in Matlab:
f=10; %frequency of the impulse in Hz
fs=f*10; % sample frequency is 10 times higher
t=0:1/fs:1; % time vector
y=zeros(size(t));
y(1:fs/f:end)=1;
plot(t,y);
I'm trying to understand the following 2 operations:
1.
t=0:1/fs:1; % time vector
the first operation generates the time matrix starting from the value 0 and the step size is 1/fs. the final value is 1.
In your second point 1:1/fs:end represents the index of array. it starts from 1 till the last value, with a step size of fs/f. it means that by starting from the value of 1, it replace every value in the y matrix to 1 [ y(1:fs/f:end) ], at a step size of fs/f
here in matlab the time t is variable whose values are ranging from 0 to 1 with a step size of 1/fs, hence all its values are stored in a matrix of one row and 101 columns known as row matrix or row vector. it does not mean that we are considering the time as a vector quantity. the time here is only a variable in matlab. in matlab we normally deal with matrices.
Well, the elements of a vector can be inserted into a array or matrix, but Matlab should not call the row or column of an array or matrix a "vector". It causes confusion.
Well, the elements of a vector can be inserted into a array or matrix, but Matlab should not call the row or column of an array or matrix a "vector". It causes confusion.