Path: news.mathworks.com!newsfeed-00.mathworks.com!NNTP.WPI.EDU!elk.ncren.net!newsflash.concordia.ca!canopus.cc.umanitoba.ca!tribune.usask.ca!news.mathforum.org!not-for-mail
From: juckou <ja79@hw.ac.uk>
Newsgroups: comp.soft-sys.matlab
Subject: Correlations image/index
Date: Wed, 03 Dec 2008 19:11:24 EST
Organization: The Math Forum
Lines: 19
Message-ID: <4754636.1228349515540.JavaMail.jakarta@nitrogen.mathforum.org>
NNTP-Posting-Host: nitrogen.mathforum.org
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: support1.mathforum.org 1228349515 4063 144.118.30.135 (4 Dec 2008 00:11:55 GMT)
X-Complaints-To: news@news.mathforum.org
NNTP-Posting-Date: Thu, 4 Dec 2008 00:11:55 +0000 (UTC)
Xref: news.mathworks.com comp.soft-sys.matlab:504852


Dear all,

I'm trying to find spatial correlations (using the matlab 'corrcoef' function) between a given variable and a given index. I've a set of satellite images of sea surface temperature (sst) from a geographical area and at different times of the year stored in a netcdf file, and I want to calculate the correlation of each pixel with a given index. I have stored the index as a 2D matrix index=[1 2 3 4 5 6 7 8 9 10 11 12...] (1 would be the value of 'index' at the first week, etc.). I'm trying to write a code in matlab that allows me to compare the first value of 'index' (moment one) with the sst value of each pixel of my first image, then the second value of 'index' with each pixel of my second image, and so on. So, at the end, I would be able to plot a figure showing the value of correlation of sst and 'index' at each pixel. So far I have managed to write this (a very poor code that it is not working...because something important is missing...):

nc=netcdf('sstall.nc','r');
ts1=index;
for i=1:size(nc{'SST'},3)
    for j=1:size(nc{'SST'},2)
          ts2=nc{'SST'}(:,j,i);
          C=corrcoef(ts1,ts2);
    end
end

close(nc)  

I don't know how to relate each (j,i) point in my images with each k value of the index at each n moment. Any suggestions on this?

Thank you very much
juckou