# How to use a contour between two curves?

2 views (last 30 days)
praveen sundararajan on 10 Apr 2022
Edited: DGM on 10 Apr 2022
I have a nozzle profile and I wish to colour the nozzle using contours. But my colouring appears outside the nozzle area.
x=linspace(0,3,31);
a=1+2.2(x-1.5)^2;
now, I have a 1D temperature array(1 x n) that I wish to express between the two curves as shown below
figure(1)
subplot(3,1,1)
axis([0 3 0 6]);
plot(x,a,'r');
hold on
plot(x,-a,'r');
Kindly help.

DGM on 10 Apr 2022
Edited: DGM on 10 Apr 2022
You can use a patch object, but you'll have to specify the colormapping. This should be fairly straightforward, as your vertices are uniformly spaced along x.
% the inputs
x = linspace(0,3,31);
y1 = 1 + 2.2*(x-1.5).^2;
y2 = -y1;
T = -cos(x/3*pi); % some arbitrary temp data
% plot a patch
patch([x fliplr(x)],[y2 fliplr(y1)],[T fliplr(T)]);
hold on
colormap(parula)
% plot curves last
axis([0 3 -6 6]);
plot(x,y1,'r');
plot(x,y2,'r');
hcb = colorbar;
In this case, T is being used essentially as color data. The relative values in T (with respect to the extrema of T) correspond to the position within the colormap.

Image Analyst on 10 Apr 2022
##### 2 CommentsShowHide 1 older comment
Image Analyst on 10 Apr 2022
Let's see your code where you attempted to implement the FAQ method. You forgot to attach it for some reason.

### Community Treasure Hunt

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

Start Hunting!