% This script demonstrates that a data matrix where the data % are all linear combinations of a two sinusoidal frequencies % of differing amplitude produces four nonzero singular values % with principal time series that are each dominated by a single % frequency sine/cosine wave. % Interval end points t_low = 0; t_high = 3; % Time step size del_t = 0.05; % Time Points T = [t_low:del_t:t_high]; % Number of time points N = length(T); % Number of genes n = 100; % Frequencies for the two sinusoids w1 = 2*pi; w2 = pi*pi; % The random phase offsets for each gene. phi = 2*pi*rand(n,1); phi2 = 2*pi*rand(n,1); % Generate the sinusoidal data matrix W1 = w1*del_t*ones(n,1)*[1:N] + phi*ones(1,N); W1 = sin(W1); W2 = w2*del_t*ones(n,1)*[1:N] + phi2*ones(1,N); W2 = 10*sin(W2); A = W1 + W2; [U,S,V] = svd(A); S = diag(S); S(1:10) % Plot first 2 "modes" figure(1); hold off; plot(T',V(:,1),'k-'); hold on; plot(T',V(:,2),'k-.'); hold on; % Plot the second pair of "modes" figure(2); hold off; plot(T',V(:,3),'k-'); hold on; plot(T',V(:,4),'k-.'); hold on; hold off;