552 EOF Warmup exercise
OK take the following piece of Matlab code and put it in the
directory where you intend to work. Name it "eoftest.m".
% eoftest.m
% This generates a data set of a sine wave with random amplitude
% lx=number of spatial points; lt=number of sample points
% kw=wavenumber of sine wave in spatial direction; xn=noise level
% The amplitude of the basic sine wave is one, so the noise should
% be of the same order, say zero to ten or so.
function x=mydata(lx, lt, kw, xn)
% get x shape
for i=1:lx
xx(i)=sin((i-1)*kw*2*3.141593/lx);
end
% get time shape of Gaussian white noise
rn=randn(lt);
% combine spatial and temporal structures
for i=1:lx
for j=1:lt
x(i,j)=rn(j)*xx(i) +xn*randn(1);
end
end
Now start Matlab in the same directory where you have put eoftest.m
>> x=eoftest(10, 100, 1, 0.) ;
>> c=x*x';
>> [u,s,v]=svd(c);
>> plot(s)
>> plot(u(1:10,1:3))
>> plot(v(1:10,1:3))
>>
The eigenvalue spectrum, s, should have only one nonzero value, the first.
The first vectors of u and v should be the first eof. The row space and
column space of a symmetric matrix are identical.
Next do the same analysis, but put in some significant noise.
>> clear all
>> x=eoftest(10, 100, 1, 2.) ;
>> c=x*x';
>> [u,s,v]=svd(c);
>> plot(s)
>> plot(u(1:10,1:3))
>> plot(v(1:10,1:3))
What changes? Does eof1 still look the same. How does the eigenvalue
spectrum look?
You can do the same analysis by direct svd of the data matrix
>> clear all
>> x=eoftest(10, 100, 1, 2.) ;
>> [u,s,v]=svd(x);
>> plot(s)
>> plot(u(1:10,1:3))
>> plot(v(1:100,1:3))
Are the functions the same as before?
How do the singular values change?
What are the v vectors now?