Using the Plot 2D Vertical Function
Show older comments
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
Dyuman Joshi
on 11 May 2023
Is this the full code?
Also, how do you call the function? What are the inputs to it? What is the expected output for the given input?
Jordan David
on 11 May 2023
Dyuman Joshi
on 11 May 2023
What are the two 2D matrices?
Answers (0)
Categories
Find more on 2-D and 3-D 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!