Azzera filtri
Azzera filtri

Remove contour line from unwanted region

8 visualizzazioni (ultimi 30 giorni)
K3iTH
K3iTH il 23 Ago 2021
Commentato: Wan Ji il 23 Ago 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])

Risposta accettata

Wan Ji
Wan Ji il 23 Ago 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 Commenti
K3iTH
K3iTH il 23 Ago 2021
Thanks Wan Ji. That is what I need. Appreciate your help!

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Contour Plots in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by