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!
figure (1)
hold on
grid on
contourf (x_isen,y_isen,M_isen,500,'LineStyle','none')
xlabel('Nozzle Length (m)')
ylabel('Nozzle Height (m)')
title('Mach Value Through Nozzle')
%% Overlay Nozzle Contour
for j=2:n_left_wave
plot([x(j-1,nwave+1);x(j,nwave+1)],[y(j-1,nwave+1);y(j,nwave+1)],...
'k','LineWidth',3)
end
% Set some limits on the axes
ylim([0, h_exit*.55]);
xlim([0, length]);
colorbar
colormap('jet')
caxis([1 3])
daspect([1,1,1]);
hold off

Accepted Answer

DGM
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]);
plot(x,ytop,'k','linewidth',2);
% add a colorbar
colormap(jet)
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

More Answers (0)

Categories

Find more on Contour Plots in Help Center and File Exchange

Products


Release

R2022a

Community Treasure Hunt

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

Start Hunting!