Clear Filters
Clear Filters

Using the Plot 2D Vertical Function

2 views (last 30 days)
Jordan David
Jordan David on 11 May 2023
Commented: Dyuman Joshi on 11 May 2023
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 Comments
Jordan David
Jordan David on 11 May 2023
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).
Dyuman Joshi
Dyuman Joshi on 11 May 2023
What are the two 2D matrices?

Sign in to comment.

Answers (0)

Categories

Find more on Line Plots in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!