Using map2mat for eof analysis!

I have a matrix mm_r of the size 361*361*36; where 36 represent the number of years
i need to make it of size 36*130321
% Get EOFs:
G = map2mat(ones(size(mm_r,3),size(mm_r,2)),mm_r);
  • *the error message is Attempted to access F(37,1); index out of bounds because size(F)=[36,361].
Error in map2mat (line 30) if F(ix,iy)>0**

2 Comments

Is mat2map from the pcatool File Exchange contribution?
Yes, it is from pcatool file excahnge.

Sign in to comment.

Answers (3)

Chad Greene
Chad Greene on 13 Mar 2017
Hi Sophia,
Be careful, because map2mat assumes the first dimension is time. For normal climate data (lon*lat*time or lat*lon*time) it's probably easier to use eof, which does all the reshaping for you.

6 Comments

I did saw the eof before, but i also saw you mentioned there about pcatool so i moved back to pcatool
My eof function is little more than a wrapper for PCATool's caleof function to make it more user friendly.
So i used this instead
[eofmap,pc] = eof(mm_r,1);
I cannot understand the result, honestly i am not even sure what to expect as a result.
Hi Sophia,
I cannot understand your result either given the information you have provided.
Sophia
Sophia on 16 May 2017
Edited: Sophia on 16 May 2017
Hi
I used your eof technique as well..Somehow, does not matter what i choose as N, I mean 2 or 3 the total of all the eof is 99.9%, is there a reason for that or i am missing something..take a look at the codes below
I changed it to 36, it seems somehow better now. is it like that ??

Sign in to comment.

** the total is 99.9% **
clear all; clc;
data= load('north_x_y_lat_lon');
datacoord = reshape(data, 361,361,4);
lat = squeeze(datacoord(:,:,3));
long = squeeze(datacoord(:,:,4));
rlong = long*pi/180.;
rlat = lat*pi/180.;
load nsidc_sid_1979_2014.mat
N1=2;
[eof_maps,pc,expv] = eof(t_u,2);
[eof_maps1,pc1,expv1] = eof(t_v,2);
figure(1);clf;iw=1;jw=N1+2;
set(gcf,'MenuBar','none');
for i=1:iw*jw
if i<= iw*jw-2
C1 = squeeze(eof_maps(:,:,i));
C2 = squeeze(eof_maps1(:,:,i));
pc_u = pc';
pc_v = pc1';
subplot(iw,jw,i);
m_proj('stereographic','lat',90,'long', 300,'radius',35,'rect','on')
m_grid('linewi',1,'tickdir','out',...
'xtick',[],'ytick',[])
m_quiver(long(1:10:361,1:10:361), lat(1:10:361,1:10:361),-C1(1:10:361,1:10:361),-C2(1:10:361,1:10:361),2,'k')
m_coast('patch',[.6 .6 .6],'edgecolor','k')
axis on
set(gca,'Xticklabel',[])
set(gca,'Yticklabel',[])
title(strcat('EOF:',num2str(i),'/',num2str(expv(i)),'%'));
else
subplot(iw,jw,iw*jw-1);
plot(pc_u(:,1),'b','DisplayName','PC of u');
hold on
plot(pc_v(:,1),'r','DisplayName','PC of v');
grid on
xlabel('time')
title('PC')
legend(num2str([1:N1]'),2);
box on
subplot(iw,jw,iw*jw);
plot(pc_u(:,2),'b','DisplayName','PC of u');
hold on
plot(pc_v(:,2),'r','DisplayName','PC of v');
grid on
xlabel('time')
title('PC')
legend(num2str([1:N1]'),2);
box on
end
end
the total again is 99.9%
clear all; clc;
data= load('north_x_y_lat_lon');
datacoord = reshape(data, 361,361,4);
lat = squeeze(datacoord(:,:,3));
long = squeeze(datacoord(:,:,4));
rlong = long*pi/180.;
rlat = lat*pi/180.;
load nsidc_sid_1979_2014.mat
N1=3;
[eof_maps,pc,expv] = eof(t_u,3);
[eof_maps1,pc1,expv1] = eof(t_v,3);
figure(1);clf;iw=1;jw=N1+3;
set(gcf,'MenuBar','none');
for i=1:iw*jw
if i<= iw*jw-3
C1 = squeeze(eof_maps(:,:,i));
C2 = squeeze(eof_maps1(:,:,i));
pc_u = pc';
pc_v = pc1';
subplot(iw,jw,i);
m_proj('stereographic','lat',90,'long', 300,'radius',35,'rect','on')
m_grid('linewi',1,'tickdir','out',...
'xtick',[],'ytick',[])
m_quiver(long(1:10:361,1:10:361), lat(1:10:361,1:10:361),-C1(1:10:361,1:10:361),-C2(1:10:361,1:10:361),2,'k')
m_coast('patch',[.6 .6 .6],'edgecolor','k')
axis on
set(gca,'Xticklabel',[])
set(gca,'Yticklabel',[])
title(strcat('EOF:',num2str(i),'/',num2str(expv(i)),'%'));
else
subplot(iw,jw,iw*jw-2);
plot(pc_u(:,1),'b','DisplayName','PC of u');
hold on
plot(pc_v(:,1),'r','DisplayName','PC of v');
grid on
xlabel('time')
title('PC')
legend(num2str([1:N1]'),2);
box on
subplot(iw,jw,iw*jw-1);
plot(pc_u(:,2),'b','DisplayName','PC of u');
hold on
plot(pc_v(:,2),'r','DisplayName','PC of v');
grid on
xlabel('time')
title('PC')
legend(num2str([1:N1]'),2);
box on
subplot(iw,jw,iw*jw);
plot(pc_u(:,3),'b','DisplayName','PC of u');
hold on
plot(pc_v(:,3),'r','DisplayName','PC of v');
grid on
xlabel('time')
title('PC')
legend(num2str([1:N1]'),2);
box on
end
end

Categories

Asked:

on 13 Mar 2017

Commented:

on 16 May 2017

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!