Use m_quiver to plot the values which are numbers and not nans
1 回表示 (過去 30 日間)
古いコメントを表示
%%Mean of sea ice drift over 36 winters (This code works perfectly fine)
mean_wint_u = nanmean(t_u,3); %t_u is 361*361*36
mean_wint_v = nanmean(t_v,3); %t_v is 361*361*36
figure(5);
clf;
m_proj('Stereographic','lat',90,'long',300,'radius',30,'rect','on');
m_grid('linewi',1,'tickdir','out',...
'xtick',6,'ytick',[72 76 80 84 88 90]);
m_coast('patch',[.7 .7 .7],'edgecolor','k');
long2 = long(1:4:361,1:4:361);
lat2 = lat(1:4:361,1:4:361);
U2 = mean_wint_u(1:4:361,1:4:361);
V2 = mean_wint_v(1:4:361,1:4:361);
idx = ~isnan(U2) & ~isnan(V2);
m_quiver(long2(idx),lat2(idx),U2(idx),V2(idx),2,'LineWidth',1,'Color','k')
And the problem is in this code its the similar code but for 6 different periods
t_pu = zeros(361,361,6);
t_pv = zeros(361,361,6);
ind2 = 1:6;
for t3 = 1:t/6;
if t3<=6
tt_u = t_u(1:361,1:361,ind2);
tt_v = t_v(1:361,1:361,ind2);
wint2_u = nanmean(tt_u,3);
wint2_v = nanmean(tt_v,3);
t_pu(:,:,t3) = wint2_u;
t_pv(:,:,t3) = wint2_v;
ind2 = ind2+6;
else
end
end
long2 = long(1:4:361,1:4:361);
lat2 = lat(1:4:361,1:4:361);
What would be the correct way to use the for statement here to use the quiver function to plot the actual values i.e. excluding NaNs
for l = 1:6;
U2(:,:,l) = t_pu(1:4:361,1:4:361,l); %This is the statement which is incorrect
V2(:,:,l) = t_pv(1:4:361,1:4:361,l); %This is the statement which is incorrect
idx(:,:,l) = ~isnan(U2,l) & ~isnan(V2,l);
end
figure(4);
clf;
for k = 1 : 6;
ax1(k) = subaxis(3,6,k, 'Spacing', 0.01,'SpacingHoriz',0,'Padding', 0, 'Margin', 0);
m_proj('Stereographic','lat',90,'long',300,'radius',35,'rect','on');
m_grid('linewi',1,'tickdir','out',...
'xtick',6,'ytick',[72 78 84 90],...
'xticklabel',[]);
m_elev('contour',[ ],'edgecolor',' ');
m_contourf(long,lat,wint2_r(:,:,k),'linestyle','none');
m_quiver(long2(idx,k),lat2(idx,k),U2(idx,k),V2(idx,k),2,'LineWidth',1,'Color','k')
caxis([-6 11])
axis tight
axis off
m_coast('patch',[.6 .6 .6],'edgecolor','k');
end
0 件のコメント
回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Vector Fields についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!