function for sampling sine function
Is there a specific reason you need to use pulstran() ? Since you have an explicit expression for your signal, you can just sample the sine wave at the specified times as follows:



function x = ssin(f0,Fs,N)

% f0 = sine wave frequency [Hz]
% Fs = sampling frequency [Hz]
% N = number of samples


dt = 1/Fs;       % Sampling period [s]
T = N*dt;        % Record window duration [s]
t = 0:dt:(T-dt); % Time vector for sampling [s]

% generate samples at the specified times
x = sin(2*pi*f0*t); % [signal units]

stem(t,x)

end

% run the function
x = ssin(1,20,60)