how can i combine 3 dimensional data and use pca function?

조회 수: 12 (최근 30일)
성낙 홍
성낙 홍 2023년 6월 27일
댓글: 성낙 홍 2023년 6월 27일
HI, I want to combine two pressure data which have longitude 160 ~ 180 & -180 ~ -150.( latitude is same.)
I wanted to use pca function with this data, and plot with m_map.
% pressure
prs1prs1 = ncread('prs1.nc','sp');
prs2 = ncread('prs2.nc','sp');
prs2(1,:,:)=[];
prs=cat(1,prs1,prs2);
[a,b,c] = size(prs);
X = reshape(prs,a*b,c)';
X = X-ones(c,a*b).*repmat(mean(X,1),c,1);
X(isnan(X))=0;
% pca
[coeff,score,latent,tsquared,explained] = pca(X);
recoeff = reshape(coeff,[201,121,351]);
% time
day1 = datetime(1979,01,01);
day2 = datetime(2022,12,31);
time = day1:calmonths(1):day2;
time=datenum(time);
%lon
prs1lon = ncread('prs1.nc','longitude');
prs1lon = double(prs1lon);
prs2lon = ncread('prs2.nc','longitude');
prs2lon = double(prs2lon);
prs2lon(1,:)=[];
prslon=[prs1lon;prs2lon];
%lat
prslat = ncread('prs1.nc','latitude');
prslat = double(prslat);
% m_map
m_proj('lambert','lon',[160 210],'lat',[50 80])
m_pcolor(prslon,prslat,recoeff(:,:,1)');
colormap(jet);
shading flat
hold on
h=m_coast('patch','w')
m_grid('box','on','out');
hold on
I tried like this, but the figure does not show whole range.
How can I solve this??
Thank you.

답변 (1개)

Mrinal Anand
Mrinal Anand 2023년 6월 27일
You can try changing the range of longitudes in the m_proj function to include a longer range of longitudinal values:
m_proj('lambert', 'lon', [160 -150], 'lat', [50 80])
You can probably adjust the longitudinal range to get the desired figure that you want.
  댓글 수: 1
성낙 홍
성낙 홍 2023년 6월 27일
Thanks for your answer, your answer helped me to solve the problem.
Range of longitudes in m_proj was not problem,
but the prslon didn't matched with the m_proj range.
So I changed the prslon range.
Thanks again.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Dimensionality Reduction and Feature Extraction에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by