You are trying to call repmatwith a floating point number. Obviously, this will not work the way you planned. repmatThe intended operation is replication of a certain size an integer number of times .
, , , 1 . , 2,4 , , 40% . 40% .
, , . , , , , , . . , 2.4, floor(0.4*fs), , , .
- :
%// Your code
clear, clc
fs = 44100; %// Define sampling frequency
t=linspace(0,2*pi,fs);
freq=1;
ya = sin(freq*t)'; %// Define signal
num_per_sec=2.1; %// Define total number of times we see the signal
%// New code
%// Get total number of integer times we see the signal
num_whole = floor(num_per_sec);
%// Replicate signal
yb=repmat(ya,num_whole,1);
%// Determine how many samples the partial signal consists of
portion = floor((num_per_sec - num_whole)*fs);
%// Sample from the original signal and stack this on top of replicated signal
yb = [yb; ya(1:portion)];
%// Your code
xxo=linspace(0,1,length(yb))';
xxi=linspace(0,1,length(ya))';
yi_t=interp1(xxo,yb,xxi,'linear');