Creating a contour plot with three row vectors
3 views (last 30 days)
I need to create a contour plot, but my input consists of three row vectors, x_isen, y_isen, and M_isen. At each coordinate of (x_isen,y_isen), I have a value of M_isen. Also M_isen only varies in the x direction so it is constant for all y values at each x coordinate. My y_isen vector is currently all zeros because I am unsure how to make it otherwise even though it should be all y values at each x. My goal is to create a similar plot as I have attached below. Please help!
xlabel('Nozzle Length (m)')
ylabel('Nozzle Height (m)')
title('Mach Value Through Nozzle')
%% Overlay Nozzle Contour
% Set some limits on the axes
DGM on 24 Apr 2022
Edited: DGM on 24 Apr 2022
I answered a similar question recently.
The only real difference is that the boundary shape would be straight lines.
% the inputs
x = linspace(0,1,25);
ytop = 0.05 + 0.2*x;
ybot = zeros(size(x));
T = 1 + x*2; % some arbitrary flow data
% plot a patch
hp = patch([x fliplr(x)],[ybot fliplr(ytop)],[T fliplr(T)]);
hp.EdgeColor = 'none';
hold on; grid on
% plot curves last
axis([0 1 0 0.3]);
% add a colorbar
hcb = colorbar;
If you want the stepped appearance of a contourf() plot (at least without the lines), you could use a shorter colormap.
If you truly want to do it with contourf(), you'll have to replicate your M vector into a 2D array. This is a similar example showing a truncated pcolor()/contourf() plot