Borrar filtros
Borrar filtros

Remove contour line from unwanted region

8 visualizaciones (últimos 30 días)
K3iTH
K3iTH el 23 de Ag. de 2021
Comentada: Wan Ji el 23 de Ag. de 2021
Hi all, I am able to plot the contour at specific level. However, I want to remove/white out some contour lines from the unwanted region (between -1 to 1 for X and Z). I can create a white space for a 1D matrix (example from other user) with the code below but I have an issue with a matrix (360x180). The code below is not working for 2D matrix. I want to remove the all the contour line when X and Z is between -1 to 1. I have included my .mat file for X_2D,Z_2D and T_2D. Thank you for your kind response.
%%Example from other user
x = -100:100;
y = -100:100;
inputData = rand(201);
inputData(abs(x)<=10,abs(y)<=10) = nan;
contourf(x,y,inputData,'LineStyle','none');
%myCode
[M,c] = contour(X_2D,Z_2D,T_2D,1.025,'k');
c.LineWidth = 1;
xlabel('$x$','Interpreter','latex')
ylabel('$z$','Interpreter','latex')
axis equal
axis([-5 5 -5 5])
pbaspect([4 3 1])

Respuesta aceptada

Wan Ji
Wan Ji el 23 de Ag. de 2021
%%Example from other user
x = -100:100;
y = -100:100;
inputData = rand(201);
inputData(abs(x)<=10,abs(y)<=10) = nan;
contourf(x,y,inputData,'LineStyle','none');
% myCode
T_2D(abs(X_2D)<1 & abs(Z_2D)<1) = NaN; % remove the all the contour line when X and Z is between -1 to 1
[M,c] = contour(X_2D,Z_2D,T_2D,1.025,'k');
c.LineWidth = 1;
xlabel('$x$','Interpreter','latex')
ylabel('$z$','Interpreter','latex')
axis equal
axis([-5 5 -5 5])
pbaspect([4 3 1])
Then the result is shown as
  2 comentarios
K3iTH
K3iTH el 23 de Ag. de 2021
Thanks Wan Ji. That is what I need. Appreciate your help!
Wan Ji
Wan Ji el 23 de Ag. de 2021
My pleasure!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Contour Plots en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by