Using map2mat for eof analysis!

2 Ansichten (letzte 30 Tage)
Sophia
Sophia am 13 Mär. 2017
Kommentiert: Sophia am 16 Mai 2017
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 Kommentare
Walter Roberson
Walter Roberson am 13 Mär. 2017
Is mat2map from the pcatool File Exchange contribution?
Sophia
Sophia am 15 Mär. 2017
Yes, it is from pcatool file excahnge.

Melden Sie sich an, um zu kommentieren.

Antworten (3)

Chad Greene
Chad Greene am 13 Mär. 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 Kommentare
Sophia
Sophia am 16 Mai 2017
Bearbeitet: Sophia am 16 Mai 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
Sophia
Sophia am 16 Mai 2017
I changed it to 36, it seems somehow better now. is it like that ??

Melden Sie sich an, um zu kommentieren.


Sophia
Sophia am 16 Mai 2017
** 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

Sophia
Sophia am 16 Mai 2017
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

Kategorien

Mehr zu Dimensionality Reduction and Feature Extraction finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by