let us consider following equation
x(t)=sum(a(i)*sin(2*pi*f(i)*t+b(i)*cos(2*pi*f(i)*t))
where i=1,2,......m and frequencies f=[f1,f2,.....fm] and t=[t1,t2,....tn]
i want to create matrix by sin(2*pi*f(i)*t) and cos(2*pi*f(i)*t),clearly it would be matrix with dimension NX2*m,i have tried following code
function [amplitudes]=determine_amplitudes(y,f,t,n,m);
X=zeros(n,2*m);
for i=1:n
for k=1:m
if mod(k,2)==1
X(i,k)=sin(2*pi*f(k)*t(i));
else
X(i,k)=cos(2*pi*f(k)*t(i);
end
end
end
end
i used mod operator to determine that if k is odd index,then there should be written sin value,else cosine value,but problem is that i am not sure that given matrix would be with dimension NX2*m,so how to create such matrix so that not exceed index of bounds of frequency array ,recall that frequency array is following f=[f1,f2,..fm],so my problem simple is how to apply m frequency at 2*m position,thanks for help
UPDATE:
let say m=3, and frequencies f=[12.5 13.6 21.7]
then we have following matrix ,also assume
n=4 t=[0.01 0.02 0.03 0.04]
sin(2*pi*f(1)*t(1)) cos(2*pi*f(1)* t(1)) sin(2*pi*f(2)*t(1)) cos(2*pi*f(2)*t(1)) sin(2*pi*f(3)*t(1)) cos(2*pi*f(3)*t(1))
nXmbecause with theifconditional it's just selecting one of sin or cos terms, isn't that right?