Using the Plot 2D Vertical Function

4 次查看(过去 30 天)
I'm in a class where I've been given a crash course on the aforementined code. I'm having trouble interpreting where I am suppose to edit in the code to create what should be a vertical cross section of data so that my 144x11 matrix is displayed as such.
The code is
function status=plot_2d_vert(ifig,x,y,var,cmin,cmax,units);
status=0;
cmap=linspecer(50);
% make a matrix of lon
[nlon,nlev]=size(y);
lon=zeros(nlon,nlev);
for k=1:nlev
lon(:,k)=x;
end
%------------------------------------------
% now plot
%------------------------------------------
h=figure(ifig);
clf(ifig);
% position the figure
set(h,'Units','pixels','Position',[700 450 620 350]);
% plot
pcolor(lon,y,squeeze(var(:,:)));
hold on;
shading interp;
caxis([cmin cmax]);
set(gca,'YDir','reverse');
set(gca,'YScale','log');
%------------------------------------------
% all aesthetics
%------------------------------------------
ylim([100 1020]);
set(gca,'Ytick',[100 250 400 550 700 850 1000]);
set(gca,'YtickLabel',[' 100';' 250';' 400';' 550';' 700';' 850';'1000'],'fontsize',14);
set(gca,'Fontsize',14);
ax=gca;
ax.TickLength=[0.025;0.025];
% colorbar
hh=colorbar('EastOutside');
axx=gca;
axx.TickLength=[0.025;0.025];
set(hh,'Position',[0.912,0.318,0.01,0.403]);
set(hh,'Fontsize',14);
set(get(hh,'Title'),'String',units,'Fontsize',14);
ylabel('Pressure, in hPa','Fontsize',16);
xlabel('Longitude, in deg','Fontsize',16);
colormap(cmap);
status=1;
  3 个评论
Jordan David
Jordan David 2023-5-11
This is the full code sans the "end" I missed on the copy and paste. The students were randomly given this and sent off to figure it out with little context. Somehow I'm suppose to take this code and two 2D matrices to output a vertical cross section of the two variables (water vapor with height).

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Orange 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by