Erasing part of contourf diagram (L-shaped diagram using contourf)

I have three matrices. First one is values of temperatures in (x,y) points, and second and third matrix is x and y coordinates, respectively. Rectangular block with temperatures is on figure(1) and it looks appropriately, but when I tried to neglect the values x>2 and y<2, to get L-shaped diagram, it doesn't look fine. Is there any solution to this problem? I submit the picture how the figure(2) should look.Fig2.jpg
Temp=[20 20 20 20 20; % y=0
18 18 18 18 18; % y=1
16 16 16 16 16; % y=2
14 14 14 14 14; % y=3
12 12 12 12 12]; % y=4
x_points=[0 1 2 3 4;
0 1 2 3 4;
0 1 2 3 4;
0 1 2 3 4;
0 1 2 3 4];
y_points=[0 0 0 0 0;
1 1 1 1 1;
2 2 2 2 2;
3 3 3 3 3;
4 4 4 4 4];
figure(1) % Rectangular block with temperatures
contourf(x_points,y_points,Temp)
figure(2) % L-shaped block with temperatures
Temp1=Temp
Temp1(1:2,4:5)=NaN
contourf(x_points,y_points,Temp1)

Answers (1)

try
ind = x_points > 2 & y_points < 2;
temp(ind) = nan;

1 Comment

Again, the same diagram like in my case. This part of the code is attached below. Probably, since we have temperature values in discrete points (integer numbers between 0 and 4), there is no way get the diagram I want. We will always have a "jump" in region (2<x<3 & 1<y<2) for this choice of NaN points.
figure(2) % L-shaped block with temperatures
Temp1=Temp
Temp1(1:2,4:5)=NaN
contourf(x_points,y_points,Temp1)

This question is closed.

Asked:

on 23 Dec 2019

Closed:

on 20 Aug 2021

Community Treasure Hunt

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

Start Hunting!